This article gives the settings you need to compile and run an ISO C++ OpenSplice application using Visual Studio for Release and Debug builds
For a more detailed explanation of general setup see setting up Microsoft Visual Studio to use ISOC++2 with OpenSplice DDS.
In order to successfully compile and run a ISOC++2 OpenSplice application, whether on Linux or Windows, several parameters must be configured. Here we will cover the latter, with Visual Studio, although the preprocessor flags and libraries are applicable to all platforms (substituting the relevant file extension).
Using ISOC++2 In Release Mode
In the Visual Studio project for the release configuration target, please set the following:
- C/C++ -> Preprocessor -> Add NDEBUG
- C/C++ -> Code Generation -> Multi Threaded DLL (/MD)
- Linker -> Input -> set dcpsisocpp2.lib and ddskernel.lib
Using ISOC++2 In Debug Mode
On Windows platforms, memory allocations are potentially different in release and debug mode and there can be issues when mixing the Release and Debug configurations across the application and API boundary. If running an application in debug mode raises an “access violation” error during the initial creation of the DDS Domain Participant, it may be that the ISO C++ 2 library needs to be recompiled for debug mode. The application and OpenSplice ISO C++ API code needs to be compiled for the same configuration in order to guarantee comparability across that boundary.
Build a Debug version of the OpenSplice ISO C++ API
Below are the instructions to build OpenSplice ISO C++ API but for more details please see the main ISO C++ API pages online or in the OpenSplice installation.
If the OSPL_HOME variables are set at the system level you can just open the custom_lib\Build_DCPS_ISO_Cpp2_Lib project in Visual Studio (otherwise you’d need to run Visual Studio from a command prompt where the variables were set).
OpenSplice 6.8.3 and later
There are “Release” and “Debug” configurations provided within the custom library Visual Studio solution, so you can just select and build these directly. This will create libraries in the main OpenSplice lib directory so they can be referenced in the same manner as any other lib file.
Pre OpenSplice 6.8.3
Otherwise, Debug may be configured as follows:
- Create a new Debug configuration of the ISO C++ custom lib by cloning the existing Release configuration (to have all of those settings). Name it Debug
- C/C++ -> Preprocessor -> Add _DEBUG (as well as leaving NDEBUG set)
- C/C++ -> Code Generation -> set Multi-threaded Debug DLL (/MDd) instead of Multi Threaded DLL (/MD)
- (Optional) To allow you to build a debug lib/dll without overwriting the existing release one
- General -> TargetName -> dcpsisocpp2d
- General -> Intermediate directory -> Debug\
- Linker -> General -> OutputFile -> dcpsisocpp2d.dll
- Linker -> Advanced -> Import Library -> ..\lib\dcpsisocpp2d.lib
- Rebuild All
Configuration for ISOC++2 application
Then after building the debug library for ISOC++2, then in the Visual Studio project for the debug configuration target of your application, please set the following:
- C/C++ -> Preprocessor -> Add NDEBUG
- C/C++ -> Code Generation -> Multi Threaded Debug DLL (/MDd)
- Linker -> Input -> set dcpsisocpp2d.lib and ddskernel.lib