How to solve the 'undefined reference to libusb' error in ros?
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} )
include_directories(/usr/local/include)
include_directories(/root/catkin_ws/src/asi_converter_real/include/asi_converter_real)
link_directories(/usr/local/lib)
link_libraries(pthread)
link_libraries(usb)
link_libraries(libASICamera.a)
link_libraries(libASICamera.so)
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 ?