ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
1 | initial version |
I have looked over very many questions and answers and tried the code offered by the answers;
When including a comment like this in your question, please always also include some links to those Q&As. Without that -- and what you've tried -- you run the risk of receiving the same advice/answer again, which wastes everyone's time.
Also: please always include information on your OS (ie: which version, how you installed it), your platform (ie: regular Intel PC? Embedded ARM board?) and your ROS installation (which version, how did you install it (using apt-get
or built from sources using catkin
?).
I moved files from
/usr/local/lib
to/opt/ros/indigo/lib
Please don't do that: until you understand things better, consider /opt/ros/*
a no-go area.
General comment: this is not a ROS 'problem', but a CMake one. In a nutshell, you haven't told CMake to generate the Makefile
statements that will cause the linker to link the labjack libraries with your program (ie: jimmy_state_publisher
). As the library isn't linked, and the linker performs a final check at the end, it sees there are various symbols (ie: function calls) you're using that it can't find, so it gives you those errors.
As to your CMakeLists.txt
:
include_directories(include ${catkin_INCLUDE_DIRS})
this tells CMake to add those directories to the include path (used to search for headers).
add_executable(jimmy_state_publisher src/jimmy_state_publisher.cpp)
this tells CMake to create a target that will result in the compilation of all source files you specify (*.cpp
, in this case only one) which will make up the executable.
target_link_libraries(jimmy_state_publisher ${catkin_LIBRARIES})
But, your executable is using functions and variables not implemented in your own code, so it'll need to get those somewhere else. That is where libraries come in, and this last CMake statement tells CMake to make sure the executable target that we defined earlier will get linked to all the libraries that we specify (in this case the libraries contained in the variable catkin_LIBRARIES
).
Now the issue is that you don't add (any of) the "Labjack U3" librar(y)(ies) here, so the linker will do its check and discover that functions like LJUSB_OpenDevice(..)
and the others are being called in jimmy_state_publisher
, but their implementations are nowhere to be found. And then it returns the error.
You'll have to add the "Labjack U3" librar(y)(ies) to the target_link_libraries(..)
statement. It should look something like:
target_link_libraries(jimmy_state_publisher labjack_u3 ${catkin_LIBRARIES})
Where I obviously made up the name labjack_u3
, you'll have to make sure you use the correct name.
Note that even though the file will most likely have a name like liblabjack_u3
, you give CMake the name wihout the lib
. It will add that for you.