Hi there.
I've been searching the internet the whole day for a solution to this problem, but I simply cannot find one.
I'm cross compiling a C++11 NDDS application for the Raspberry Pi using RTI Connext DDS 5.2. I'm using a self compiled toolchain for gcc 5.2 following the instructions in the HOW TO for NDDS on Raspberry Pi.
I am facing a problem with the exceptions in the dds::core. My code compiles just fine, but the linking fails, when I implement error handling with exceptions. The error looks like this:
[INFO] Starting link {4.8 -static-libgcc -L/home/sune/git/cobraid/RemoteEyeUnit/pi/target/nar/dds-1.0.0-arm-Linux-gpp-shared/lib/arm-Linux-gpp/shared -ldds-1.0.0 -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bdynamic -lnddscppz -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bdynamic -lnddscz -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bdynamic -lnddscpp2z -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bdynamic -lnddscorez -Bdynamic -ldl -lnsl -lm -lpthread -lrt -fexceptions -lstdc++}
[INFO] Starting link {4.8 -static-libgcc -L/home/sune/git/cobraid/RemoteEyeUnit/pi/target/nar/dds-1.0.0-arm-Linux-gpp-shared/lib/arm-Linux-gpp/shared -ldds-1.0.0 -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bdynamic -lnddscppz -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bdynamic -lnddscz -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bdynamic -lnddscpp2z -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bdynamic -lnddscorez -Bdynamic -ldl -lnsl -lm -lpthread -lrt -fexceptions -lstdc++}
[ERROR] /home/sune/git/cobraid/RemoteEyeUnit/pi/target/nar/obj/arm-Linux-gpp/pi.o: In function `cobraid::Subscriber::createDataReader()':
[ERROR] pi.cpp:(.text._ZN7cobraid10SubscriberI7ControlE16createDataReaderEv[_ZN7cobraid10SubscriberI7ControlE16createDataReaderEv]+0x1c8): undefined reference to `dds::core::InvalidArgumentError::InvalidArgumentError(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)'
I've tried to run the code on the host machine (Ubuntu 14.04LTS 64-bit) without static linking stdc++, and it runs without any problems.
I'm using a Maven plugin named Maven NAR for compiling my C++11 project, which gives the information and error syntax above.
Any ideers why the dds::core exceptions doesn't seem to work on the Raspberry Pi?
Best regards
Sune
Software Engineer student at Aarhus University Denmark
Hi Sune,
I have taken a look at the makefile that rtiddsgen generates for building a C++11 example that is going to run on a Raspberry Pi (armv6vfphLinux3.xgcc4.7.2). And this is what I have found:
It looks like require passing the
-std=c++0x
compiler flag, but I do not know whether you are passing it already. If you are not, please add it to your build.If this does not work, can you share with us the makefile you are using or a more verbose output including both the command you use to compile and link? Also, can you share some instructions on how to install the toolchain you are using?
Thanks,
Fernando.
Hi Fernando.
Thank you for the answer.
Since I'm using Maven instread of make to build my project, I do not have a makefile, but I can provide The compile and linker options that I'm using.
When I sat up the project I did the same thing, namely set the flags that where set in the autogenerated makefile for the idl's.
I've attached my pom.xml file (which is defining the build process). Some of the NDDS libraries are linked in the linker section in the the nar plugin section in the pi profile. Other settings are loaded from the other attachment aol.properties (renamed to aol.txt because the forum don't like tike the .properties extension). I hope it's not to confusing.
The toolchain was built using the crosstool-ng. We had to built the latest development built to support gcc5.2. This is done using the following commands:
There might be some dependencies which has to be installed as well. I had to install the following dependencies before running ./configure --enable-local:
The following properties are sat in the menuconfig
thanks again.
Sune
ps. When I'm not using the built in dds exceptions, then it builts, links and runs with no problems.
Hi Sune,
We just noticed that the order in which the libraries are linked is swapped and that may be causing your problem. You should link against the C++ library before linking against the C, and Core libraries (i.e., the order should be
-lnddscpp2z -lnddscz -lnddscorez
). Even though we have not tried to build your specific toolchain with our toolchain based on 4.7.2 this defintiely causes problem. Note also that the order in which the libraries are linked is right in other parts of your pom.xml file.Here is how you can modify your pom.xml (I think the order in which the libraries are linked is right in other parts of your pom.xml file):
We also noted that these libraries are marked as
shared
, but they arestatic
libraries. I think that is what adds -BDynamic to the linker.Please let me know if this fixes your issue,
Fernando.
Hi Fernando.
I've changed the order in which the libraries are loaded, and changed the linking to static, but it doesn't seem to make a difference.
Starting link {4.8 -static-libgcc -L/home/sune/git/cobraid/RemoteEyeUnit/pi/target/nar/dds-1.0.0-arm-Linux-gpp-shared/lib/arm-Linux-gpp/shared -ldds-1.0.0 -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bstatic -lnddscpp2z -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bstatic -lnddscppz -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bstatic -lnddscz -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bstatic -lnddscorez -Bdynamic -ldl -lnsl -lm -lpthread -lrt -fexceptions -lstdc++}
[INFO] Starting link {4.8 -static-libgcc -L/home/sune/git/cobraid/RemoteEyeUnit/pi/target/nar/dds-1.0.0-arm-Linux-gpp-shared/lib/arm-Linux-gpp/shared -ldds-1.0.0 -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bstatic -lnddscpp2z -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bstatic -lnddscppz -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bstatic -lnddscz -L/home/sune/rti_connext_dds-5.2.0/lib/armv6vfphLinux3.xgcc4.7.2 -Bstatic -lnddscorez -Bdynamic -ldl -lnsl -lm -lpthread -lrt -fexceptions -lstdc++}
[ERROR] /home/sune/git/cobraid/RemoteEyeUnit/pi/target/nar/obj/arm-Linux-gpp/pi.o: In function `main':
[ERROR] pi.cpp:(.text+0x324): undefined reference to `dds::core::NullReferenceError::NullReferenceError(std::__cxx11::basic_string<char, std::char_traits, std::allocator > const&)' [ERROR] collect2: error: ld returned 1 exit status
I've inserted another exception just for test purposes, but that shouldn't make a difference. I still compiles fine, but the linking fails. The library dds-1.0.0 is a maven dependency containing the classes that I generated from my IDL, in case you wonder what the dynamic linking is about.
If I remove the library nddscpp2z from the linker, then there is an undefined reference to the destructor as well as an undefined reference to the constructor, so it seems like parts of the implementation is found during the linking process, but the constructor seems to be the one causing the problem.
Here is how I call the constructor:
const std::string msg= "Test";
throw dds::core::NullReferenceError(msg);Sune
Hi Sune,
Do you get the same problem if you compile a C++03 example instead of C++11?
Alex
Hi Alex.
Everything works as it should as long as I don't use the rti core exceptions. I have no problems in using my own custom exceptions. C++03 is not an option since I'm using C++11 throughout the entire project, and the dds core exceptions uses a lot of c++11 themselves including the move operations as far as I know.
Sune
Hi Alex and Fernando.
Thanks for your sugestions. I never got it to work with RTI Exceptions, but for now that's allright. I'm using some custom exceptions instead. It is still a bit weird why it wasn't possible though
//Sune