Undefined Reference when Linked to Library

2 posts / 0 new
Last post
cjb
Offline
Last seen: 3 years 7 months ago
Joined: 09/01/2020
Posts: 1
Undefined Reference when Linked to Library

Hello,

I'm a bit stuck trying to get a basic example running.  I am using the connext_dds C++ example for hello_builtin.  I have a .bashrc set up like so: 

export NDDSHOME=/home/cbarnes/.m2/rti/x86_64 export RTI_LICENSE_FILE=/home/cbarnes/.m2/rti_license.dat export LD_LIBRARY_PATH=/home/cbarnes/.m2/rti/x86_64/lib/x64Linux3gcc4.8.2 export LDFLAGS="-L/home/cbarnes/.m2/rit/x86_64/lib/x64Linux3gcc4.8.2 -L/home/cbarnes/.m2/rti/x86_64/include/ndds -ldl -lnsl -lm -lpthread -lrt -Wl,--no-as-needed" export CFLAGS="-DRTI_UNIX -m64 -I/home/cbarnes/.m2/rti/x86_64/include -I/home/cbarnes/.m2/rti/x86_64/include/ndds -I/usr/include/x86_64-linux-gnu"

And when I try to compile the example program I get a ton of undefined reference to which I presume is a link problem.  The paths above are correct so it cannot be that so I'm really lost at what would be causing this.  Here is some example output:

Hello.o: In function `startApplication(CommandLineArgumen ts const&)': Hello.cxx:(.text+0x394): undefined reference to `DDSDomainParticipantFactory::ge t_instance()' Hello.cxx:(.text+0x3b7): undefined reference to `DDS_PARTICIPANT_QOS_DEFAULT' Hello.cxx:(.text+0x425): undefined reference to `DDSStringTypeSupport::get_type_ name()' Hello.cxx:(.text+0x450): undefined reference to `DDS_TOPIC_QOS_DEFAULT' Hello.cxx:(.text+0x57e): undefined reference to `DDSDomainParticipantFactory::ge t_instance()'

Offline
Last seen: 2 months 2 days ago
Joined: 09/23/2018
Posts: 62

Have you checked out our new  Getting Started Guide?

https://community.rti.com/documentation

Your installation location is not typical but it should be okay.   I say this because your  NDDSHOME is set to "/home/cbarnes/.m2/rti/x86_64"  versus something like "/home/cbarnes/rti_connext_dds-6.0.1".

Instead of setting all those environmental variables manually,   try running our helper script:

      source /home/cbarnes/.m2/rti/x86_64/resource/scripts/x64Linux3gcc4.8.2.bash

This will set up the NDDSHOME and library paths.     This all assumes you have a sane installation --- i.e. installed via a  host run package and target rtipkg's. 

(e.g. rti_connext_dds-6.0.1-pro-host-x64Linux.run,  rti_connext_dds-6.0.1-pro-target-x64Linux3gcc4.8.2.rtipkg,  etc.)

You can sanity check these steps by  starting our launcher GUI:

     $NDDSHOME/bin/rtilauncher

If this works,  it should also create an  rti_workspace  directory in you home path.  This contains examples and some user configuration files.  The README.txt files in each example directory should help if you can get to this point.