Building and Running VxWorks 7 Boost C++ Applications

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

Windows Screenshot Of Creating The RTP Based On The VxWorks Source Build (VSB) boostvsb

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”.

Windows Screenshot Of Renaming A Source File

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.”

Locate the Geometry Example Code

Figure 3: Locate the Geometry Example Code


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

Select Index of Polygons Stored in Vector

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.

Copying Source Code into the RTP Project

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

Add Core Boost Library to the RTP Project

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.

Create a VxWorks Simulator target connection

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.

Run the Boost Polygon Application

Figure 8: Run the Boost Polygon Application

Browse Category

Join our DO-178C group on LinkedIn

Got A Project In Mind?

We fix, develop and test embedded software for the aerospace & defence industry specialising in DO-178C safety-critical testing. Speak to us. We have laser focus, unprecedented attention-to-detail and provide phenomenal value.