ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

ROS-kinetic (C++11) resource retriever undefined references

asked 2018-09-06 03:31:56 -0500

teshansj gravatar image

updated 2018-09-06 03:39:18 -0500

I need to get an MySQL query from a file. For that I a trying to use this example. But when I have resource_retriever::Retriever r; in the code, I get the following errors.

resource_retriever::Retriever r; is the line causing the error and I don't get it. Any idea? (The header files are included and the files are present - I checked)

[ 95%] Building CXX object xxxxx/CMakeFiles/xxxxx.dir/src/xxxxx.cpp.o
[100%] Linking CXX executable /home/teshanl/catkin_ws/devel/lib/xxxxxx/xxxxxx
CMakeFiles/xxxxxx.dir/src/xxxxxx.cpp.o: In function `main':
xxxxx.cpp:(.text+0xd9): undefined reference to `resource_retriever::Retriever::Retriever()'
xxxxx.cpp:(.text+0x132): undefined reference to `resource_retriever::Retriever::get(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const
&)'
xxxxx.cpp:(.text+0x1a0): undefined reference to `resource_retriever::Retriever::~Retriever()'
xxxxx.cpp:(.text+0x243): undefined reference to `resource_retriever::Retriever::~Retriever()'
collect2: error: ld returned 1 exit status
xxxxx/CMakeFiles/xxxxx.dir/build.make:117: recipe for target '/home/teshanl/catkin_ws/devel/lib/xxxxx' failed
make[2]: *** [/home/teshanl/catkin_ws/devel/lib/xxxxx] Error 1
CMakeFiles/Makefile2:1836: recipe for target 'xxxxx/CMakeFiles/xxxxxx.dir/all' failed
make[1]: *** [xxxxx/CMakeFiles/xxxxxx.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j4 -l4" failed
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
2

answered 2018-09-06 03:43:25 -0500

gvdhoorn gravatar image

updated 2018-09-06 03:53:21 -0500

This seems like a linker error. How are you linking the resource_retriever libraries? Can you show your CMakeLists.txt?


Edit:

Adding resource_retriever to find_package did the trick. But still when I include something like this, how do I know what to add to the CMakeLists.txt

As to your specific question "what to add to CMakeLists.txt": in case of C++ and Python the rule is relatively straightforward: if you use anything from a package, that package becomes a dependency of your package.

In those cases you have to add the dependency to your package.xml and your CMakeLists.txt if you are working in C++.

If you are using Python, only the package.xml needs to be updated (as Python doesn't have any build dependencies (or at least: regular, simple Python packages don't)).

See the Catkin documentation on the general subject.

edit flag offensive delete link more

Comments

2

I guess you haven't specified the the CMakeLists.txt correctly. Make sure you have set this up correctly in the find_package part. Please post the CMakeLists.txt to get more help. ... What @gvdhoorn said :-D

mgruhler gravatar image mgruhler  ( 2018-09-06 03:43:29 -0500 )edit

Yes I didn't do any edit to the CMakeLists.txt. What should I add? And when I include something like this, how do I know what to add to the CMakeLists.txt

teshansj gravatar image teshansj  ( 2018-09-06 03:46:22 -0500 )edit

Please show us your current CMakeLists.txt, then we can suggest edits.

But in general, see the Catkin documentation on that subject.

gvdhoorn gravatar image gvdhoorn  ( 2018-09-06 03:48:10 -0500 )edit

Adding resource_retriever to find_package did the trick. But still when I include something like this, how do I know what to add to the CMakeLists.txt

teshansj gravatar image teshansj  ( 2018-09-06 03:48:56 -0500 )edit

@gvdhoom Sorry this is work related so I can't share files without some redaction which takes time :)

teshansj gravatar image teshansj  ( 2018-09-06 03:52:59 -0500 )edit
2

Sorry this is work related so I can't share files without some redaction

Then the accepted workflow would be to create an MWE that exhibits the same problem but does not contain anything "work related".

But that is not necessary here, as I believe we've found the issue.

gvdhoorn gravatar image gvdhoorn  ( 2018-09-06 03:54:25 -0500 )edit
2

Just for reference MWE=minimal working example. See also SSCCE

mgruhler gravatar image mgruhler  ( 2018-09-06 04:09:55 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2018-09-06 03:31:56 -0500

Seen: 454 times

Last updated: Sep 06 '18