how to use so file in ros
Hello, I want to use a .so file in the ros. And I add the .h and .so file in the /usr/include/ What else should I do? Thanks very much!
ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange |
Hello, I want to use a .so file in the ros. And I add the .h and .so file in the /usr/include/ What else should I do? Thanks very much!
Putting files by hand into /usr/include isn't a nice solution to your problem.
If this header file and library is contained in a debian package then the perfect solution is to simply depend on that package.
If this isn't the case but you have the source code of the library you can create an own package for it.
These two steps are recommended in the ROS Wiki Using thrid party libs.
If you haven't got access to the code you out the header and library inside your package and link the library withtarget_link_libraries
Edit:
I wouldn't put everything in src
. I would put the headers in include
and the shared objects in lib
. In your CMakeLists.txt there's a boilerplate target_link_libraries
. Add there the location of the shared object.
For example:
target_link_libraries(your_node ${catkin_LIBRARIES} ${PROJECT_SOURCE_DIR}/lib/libxyz.so)
Thanks very much! I haven't got access to the code. I have put the files .h and .so in ~/catin_ws/src/beginner_tutorials/src and I don't know how to write the CMakeLists, would you please tell me the details on how to write "target_link_library" and other place need to write. Thanks!
Thanks very much! And I wonder how to use the function in .so. When I just include ".h", and use the function in the .so, catkin_make say cannot find the function. If I need #include "dlfcn.h" and use dlopen and dlsym to get the function? Thanks a lot!
Hi..I a have a doubt here...
whats is this for?
@khairulizwan This compiles a library called iarm_exact_dynamics from the given source file.
Still in doubt/unclear about this. I am trying the create the iARM package. iARM manufacturer provided the .h file, .lib file and also .so file. Are this procedure correct: 1. copy the .h file --> include (mkdir -p include?) 2. copy the .so file --> lib (mkdir -p lib?) 3. edit the CMakelist.txt
@khairulizwan yes, I'd say that's the correct approach. I never worked with .lib files but it should work the same way.
Asked: 2014-08-13 02:13:11 -0600
Seen: 4,217 times
Last updated: Aug 14 '14