VxWorks

Building and Running VxWorks-7 Boost C++ Applications

by | Nov 9, 2020 | VxWorks

1 Introduction

The Boost project provides a comprehensive set of peer-reviewed, portable C++ source libraries that work well with the C++ Standard Library.

VxWorks is a Real Time Operating System built by Wind River.

VxWorks supports a subset of the Boost C++ library. The supported libraries are:

– Atomic
– Chrono
– Container
– Context
– Contract
– Date Time
– Exception
– Filesystem
– Graph
– Log
– Math
– Program Options
– Random
– Regex
– Serialization
– Timer
– Type Erasure
– BOOST Tests

In a previous blog, we explained how to build a boost enabled VxWorks kernel.

This blog describes how to port some boost example code from the boost.org website and run it on the VxWorks target.

 

2 Prerequisites

These instructions assume that you are using:

– A Windows workstation with the following installed on it:
– Wind River VxWorks 7, SR0620
– Git for Windows
– You have completed the previous blog, “Adding VxWorks-7 Boost C++ Library Support”:
https://harmonicss.co.uk/vxworks/adding-vxworks-7-boost-c-library-support/

 

3 Related Documentation

For more information on these topics, refer to:

Wind River documentation:
VxWorks Support for Third-Party Software

Non-Wind River documentation:
https://www.boost.org/

 

4 Create a Real Time Process (RTP) Project in Wind River Workbench

4.1 Create the RTP based on the VxWorks Source Build (VSB) boostvsb

You must create an RTP project based on the boost enabled VxWorks project from the previous blog.

In Workbench, do the following:

File > New > Wind River Workbench Project

Select a Real Time Process Project

bav_pic1.JPG

Figure 1: Select the RTP Build Type

Name the project “boostapp”.

You must base this project on the VSB you created in the previous blog. The VSB was called “boostvsb.” Select Browse to the file boostvsb/vsb.vxconfig to base the RTP project on “boostvsb.”

 

4.2 Rename rtp.c as rtp.cpp

The RTP project source file must be renamed to “rtp.cpp” because this boost source file will be C++ not C source code so must be built correctly.

Right-click on “rtp.c” in the Workbench Project Explorer view, select Rename and set the file name to “rtp.cpp”.

bav_pic2.JPG

Figure 2: Rename the Source File

 

5 Locate Boost Library Example Code

5.1 Navigate to the boot.org website

From your web browser, navigate to https://www.boost.org.

The “boostvsb” project was built to include the boost match libraries, so we will select some boost.org example code that uses the math
library.

 

5.2 Locate the Geometry Example Code

Select the boost “Geometry Library” example. Navigate to https://www.boost.org/doc/libs/1_54_0/libs/geometry/doc/html/index.html

Under “Spatial Indexes,” click “Examples.”

bav_pic3.JPG

Figure 3: Locate the Geometry Example Code


Select the example, “Index of polygons stored in vector.”

bav_pic4.JPG

Figure 4: Select Index of Polygons Stored in Vector

 

This presents example source code. The application uses the boost math library to create a tree of polygon math objects and then
interrogate and output their values.

Highlight this source code and copy it.

 

6 Package Boost Application As an RTP

6.1 Copy the source code to the rtp.cpp file

Make sure that you copy and replace the “rtp.cpp” file contents with all the boost website example source lines.

bav_pic5.JPG

Figure 5: Copy the Source Code into the RTP Project

6.2 Add the boost_system Library to the RTP Build Properties

Right-click on the boostapp RTP and select Properties.

Select Build Properties, Libraries.

Click Add to all, select Add library file (-I) and type:

-I boost_system

bav_pic6.JPG

Figure 6: Add Core Boost Library to the RTP Project

Click Apply and Close, and click Yes to reindex the project.

Now re-build the project. The build should complete successfully.

If you see any build errors that indicate boost libraries are missing, you must add those libraries manually from this Build Properties, Libraries
dialog box.

Note: if you use the boost thread libraries in your RTP code, you must add -I boost_thread as an additional RTP library.

 

7 Run the boost Application RTP

7.1 Launch the VxWorks Simulator Target from Workbench

From the Workbench Target Connection window, create a VxWorks simulator connection for the “boostvip” VIP project that you created in
the previous blog.

bav_pic7.JPG

Figure 7: Create a VxWorks Simulator target connection

Launch the target

 

7.2 Adjust Kernel Scheduler to Enable Time Slicing

From the VxWorks target kernel shell, type the following:

-> kernelTimeSlice(1)

Boost applications run more successfully on this VxWorks kernel configuration.

 

7.3 Run the bootapp RTP on the target

Right-click the “boostapp” project in Workbench and select Run/Debug Real Time Process.

Observe the boost polygon application runs on the target and generates outputs from the VxWorks simulator target console.

bav_pic8.JPG

Figure 8: Run the Boost Polygon Application

Got A Project In Mind?

Our levels of professionalism and commitment to our clients results in a long waiting list for projects. Let us know in advance if you might need us.