a problem of linking external libraries
Hi All,
I encountered a problem while linking a ROS program against some external libraries. I am trying to link my ROS program against Xenomai libraries. To make sure Xenomai libraries have been successfully installed in my OS (Ubuntu 10.10), I built a simple program (non-ROS) with gcc like this:
gcc -I/usr/xenomai/include -D_GNU_SOURCE -D_REENTRANT -D__XENO__ -Wall -pipe -lnative -L/usr/xenomai/lib -lxenomai -lpthread -lrtdk hellworld.c -o helloworld
No problems arise here, and I got the executable.
To build my ROS programs (take as an example the tutorial program at the ROS website ), I add the following commands to CMakeLists.txt:
rosbuild_add_executable(listener src/listener.cpp)
include_directories(/usr/xenomai/include)
add_definitions(-D_GNU_SOURCE -D_REENTRANT -D__XENO__)
rosbuild_add_compile_flags(listener -Wall -pipe)
link_directories(/usr/xenomai/lib)
target_link_libraries(listener native xenomai pthread rtdk)
That says, I want to link the “listener” node against some Xenomai libraries, like “native”, “xenomai”, etc. However, when I rosmake’d the whole package, I got this error:
Linking CXX executable ../bin/listener
/usr/bin/ld: cannot find -lnative
/usr/bin/ld: cannot find -lxenomai
collect2: ld returned 1 exit status
It seems rosbuild did not search libraries in “/usr/xenomai/lib” which is supposed to specified by link_directories(/usr/xenomai/lib)
. Did I miss something to tell rosbuild to search libraries in “/usr/xenomai/lib”?
With many thanks,