ROS Resources: Documentation | Support | Discussion Forum | Index | Service Status | ros @ Robotics Stack Exchange
Ask Your Question
0

cannot find libraries when linking

asked 2011-03-08 02:57:03 -0600

tomurillo gravatar image

updated 2011-03-08 03:24:49 -0600

Tully gravatar image

Hi, I find the following error message when trying to compile my code, by using the "make" command. All the required libraries (.so and .a) are in the /lib folder of my project source directory. What am I doing wrong?

Error message:

Linking CXX executable bin/basic_soar_test
/usr/bin/ld: cannot find -lElementXML
collect2: ld returned 1 exit status
make[2]: *** [bin/basic_soar_test] Error 1
make[1]: *** [CMakeFiles/basic_soar_test.dir/all] Error 2
make: *** [all] Error 2

The contents of my CMakeLists file are:

cmake_minimum_required(VERSION 2.4.6)
include($ENV{ROS_ROOT}/core/rosbuil

rosbuild_init()

set(EXECUTABLE_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/bin)
set(LIBRARY_OUTPUT_PATH ${PROJECT_SOURCE_DIR}/lib)

rosbuild_add_executable(basic_soar_test example/basic_soar_test.cpp)
target_link_libraries(basic_soar_test ElementXML ConnectionSML SoarKernelSML ClientSML)

Thanks in advance!

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
3

answered 2011-03-08 06:13:42 -0600

dornhege gravatar image

You need to set the link directory to where the libraries are using link_directories(dir).

edit flag offensive delete link more

Comments

How do you do the above?

gowtham gravatar image gowtham  ( 2013-10-02 08:02:51 -0600 )edit

link_directories(DIR)

dornhege gravatar image dornhege  ( 2013-10-02 08:16:29 -0600 )edit

@dornhege Hi,I am a complete beginner in ROS. Can you please explain in detail how to "set the link directory to where the libraries are using link_directories(dir)"?Thanks in advance

gowtham gravatar image gowtham  ( 2013-10-03 04:41:06 -0600 )edit

This is literally the command to use in CMakeLists.txt, just replace dir by the directory that you need to set.

dornhege gravatar image dornhege  ( 2013-10-03 06:12:39 -0600 )edit

I have the same issue, but I did put "link_directories(/usr/local/lib)" where i copied my *.so file. When I try to make my pkg on a different machine I get the same error. Why?

zweistein gravatar image zweistein  ( 2013-12-16 21:58:00 -0600 )edit

Probably because the library is not there? If the library is build with ROS there are other possibilities to link.

dornhege gravatar image dornhege  ( 2013-12-16 22:40:44 -0600 )edit

My lib is there, i copied and verified it. But i still get the error. It is not a ROS lib, but an external one, related to OpenCV.Update: the lib path was /usr/local/lib. This works on my PC but on an other one doesn't. But on the other PC if I set the lib path to: source_project_dir/src and copy my lib there, than it Works, WHY?

zweistein gravatar image zweistein  ( 2013-12-17 00:13:58 -0600 )edit

This doesn't seem like exactly the same problem, so please open a new question and include all exact path for all libraries you need + the CMakeLists.txt and any error messages.

dornhege gravatar image dornhege  ( 2013-12-17 02:40:48 -0600 )edit

Question Tools

1 follower

Stats

Asked: 2011-03-08 02:57:03 -0600

Seen: 7,365 times

Last updated: Mar 08 '11