Modern C++ API with GCC > 5.1 in Connext 5.2.x
GCC 5.1 introduced a new version of libstdc++ with a library ABI that includes new implementations of std::string and std::list (see in GCC online documentation). This new ABI breaks backwards compatibility with applications and libraries linked against older versions of libstdc++ using std::string or std::list. You can find more information about this change in the online documentation of gcc.
RTI Connext DDS 5.2.3 provides libraries for Modern C++ API (i.e., C++03 or C++11) built with different versions of GCC, including GCC 4.8.2. However, it lacks official support for applications linked with GCC > 5.1. Therefore, if you try to link application code built with GCC > 5.1 RTI Connext DDS libraries that are built with GCC < 5.1, the compilation will fail due to link errors similar to the following:
file.cxx:(.text+0x12781): undefined reference to `getValue(std::__cxx11::basic_string<char, std::char_traits<char="">, std::allocator > const&)'
There are two workarounds to solve this situation.
1. Using the _GLIBCXX_USE_CXX11_ABI macro to select the old ABI
#define _GLIBCXX_USE_CXX11_ABI 0
Note that this solution could cause conflicts with other third*party libraries compiles with the new version of gcc without that define.
2. Install the latest version of GCC supported in 5.2.3 in your system.
To install a version of gcc, you can do it with a package manager or compiling the source code. For example, see steps below to install gcc 4.8.0:
- Create a build directory
mkdir gcc-build && cd gcc-build
- Download the source code (
wget http://www.netgull.com/gcc/releases/gcc-4.8.0/gcc-4.8.0.tar.bz2
, e.g.) - Unzip the file (
tar -xvjf gcc-4.8.0.tar.bz2
) - Install the necessary libraries:
libgmp-dev
libmpfr-dev
libmpc-dev
Libc6-dev
- Configure the compilation:
./gcc-4.8.0/configure --prefix=/opt/gcc/4.8.0
- Run
make
- Run
sudo make install
Verify that the installation finished correctly running
gcc --version
After that, there won’t be any more errors related to the compatibility with std::string.