Rosanswers logo

I am trying to transfer a camera(non-uvc) stream program to ros platform.

I've already got the camera driver running

and Makefile is like this:

g++ main.cpp -o test_gui -g -I /usr/local/include -L /usr/local/lib -D_LIN -D_DEBUG -L../lib/x64 -I../include -lASICamera -lpthread -lusb -DGLIBC_20 -m64 -lrt -I/opt

Now I want to do this in a ros node, so I write a node in which the CMakelists is like this:

include_directories( ${catkin_INCLUDE_DIRS} )








add_executable(asi_converter_real src/asi_converter_real.cpp)

target_link_libraries(asi_converter_real ${catkin_LIBRARIES})

And the Makefile line generated into /catkin_ws/build/***/ is like this:

/usr/bin/c++ CMakeFiles/asi_converter_real.dir/src/asi_converter_real.cpp.o -o /root/catkin_ws/devel/lib/asi_converter_real/asi_converter_real -rdynamic -L/usr/local/lib -lpthread -lusb -Wl,-Bstatic -lASICamera -Wl,-Bdynamic -lASICamera

But it seems that the system cannot find the dynamic libraries of libusb, coz' it reports

undefined reference to `libusb_set_configuration'

undefined reference to `libusb_claim_interface'

/usr/local/lib/libASICamera.a(ASI174MM.o): In function `WorkingFunc(void*)':

undefined reference to `libusb_bulk_transfer'

undefined reference to `libusb_bulk_transfer'

[1]Could anyone tell me how to solve this problem ?

[2]How to find the .a and .so of libusb in my computer ? (I am sure I have them, coz' I can pkg-config --cflags/--libs them)

[3]How could I explicitly link a dynamic library in ros CMakelists ? or just link_libraries(usb) is enough for both static and dynamic libriries ?

Originally posted by fromandto on ROS Answers with karma: 27 on 2014-11-25

Post score: 0


1 Answer 1


Rosanswers logo

You shouldn't link to both static and dynamic libraries. One or the other is sufficient.

In your case, instead of linking to libASICamera.a and libASICamera.so, you should just do:


And cmake will find the appropriate static or dynamic library depending on how you're linking your executable.

Also note that if your libraries have undefined symbols the linking order matters - libraries with undefined symbols should be listed first, and the libraries which contain those symbols should be listed later.

Finally, the link_libraries() command is pretty heavy-handed; it will cause all of your executables to be linked against every library you specify. Use target_link_libraries() instead, and note that you can list multiple libraries in a single linking command.

Maybe try:

target_link_libraries(asi_converter_real ${catkin_LIBRARIES} pthread ASICamera usb)

Originally posted by ahendrix with karma: 47576 on 2014-11-25

This answer was ACCEPTED on the original site

Post score: 1

Original comments

Comment by fromandto on 2014-11-25:
thx very much, it's done.


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.