0
$\begingroup$

Rosanswers logo

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!


Originally posted by tomurillo on ROS Answers with karma: 55 on 2011-03-08

Post score: 0

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

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


Originally posted by dornhege with karma: 31395 on 2011-03-08

This answer was ACCEPTED on the original site

Post score: 3


Original comments

Comment by gowtham on 2013-10-02:
How do you do the above?

Comment by dornhege on 2013-10-02:
link_directories(DIR)

Comment by gowtham on 2013-10-03:
@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

Comment by dornhege on 2013-10-03:
This is literally the command to use in CMakeLists.txt, just replace dir by the directory that you need to set.

Comment by zweistein on 2013-12-16:
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?

Comment by dornhege on 2013-12-16:
Probably because the library is not there? If the library is build with ROS there are other possibilities to link.

Comment by zweistein on 2013-12-17:
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?

Comment by dornhege on 2013-12-17:
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.

$\endgroup$

Your Answer

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