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

ros add third party library but compilation does not pass

asked 2017-10-17 00:20:30 -0500

s201761315 gravatar image

updated 2017-10-17 09:05:27 -0500

jayess gravatar image

I want to load third party library ,but compilation does not pass .How to solve it. my cmakefile.txt:

ink_directories(${catkin_LIB_DIRS} lib)
add_executable( testusbcan src/testusbcan.cpp) 
target_link_libraries(testusbcan ${catkin_LIBRARIES} controlcan)
include_directories(/home/exbot/catkin_ws/src/beginner_tutorials/include/head )
TARGET_LINK_LIBRARIES(testusbcan -lcontrolcan)

terminal displayed:

CMakeFiles/testusbcan.dir/src/testusbcan.cpp.o: In function `main':
testusbcan.cpp:(.text+0x21): undefined reference to `VCI_OpenDevice(unsigned int, unsigned int, unsigned int)'
collect2: error: ld returned 1 exit status
make[2]: *** [/home/exbot/catkin_ws/devel/lib/beginner_tutorials/testusbcan] Error 1
make[1]: *** [beginner_tutorials/CMakeFiles/testusbcan.dir/all] Error 2
make: *** [all] Error 2
Invoking "make -j1 -l1" failed
exbot@ubuntu:~/catkin_ws$
edit retag flag offensive close merge delete

1 Answer

Sort by » oldest newest most voted
0

answered 2017-11-05 14:34:59 -0500

Ed Venator gravatar image

I assume that VCI_OpenDevice is in libcontrolcan.so. What directory is libcontrolcan.so located?

CMake's link_directories(...) macro resolves relative paths from the source directory (reference). Is <package_path>/lib/ the directory that contains libcontrolcan.so? If not, you'll have to provide the full path to that directory. Hardcoding a full path is a fragile solution, so I suggest you read about How to Find Libraries in CMake.

edit flag offensive delete link more

Question Tools

2 followers

Stats

Asked: 2017-10-17 00:20:30 -0500

Seen: 244 times

Last updated: Nov 05 '17