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

Linking CXX executable error-- /usr/bin/ld: cannot find

asked 2016-06-24 22:05:51 -0500

rohin gravatar image

updated 2022-01-22 16:16:32 -0500

Evgeny gravatar image

I am building a hardware interface for my robot using the Dave Coleman's template package ros_control_boilerplate

I am having problems building my package. Relevant snippets of my CMakeLists.txt look like:

include_directories(include ${catkin_INCLUDE_DIRS})

add_library(nymble_hw_interface src/nymble_hw_interface.cpp)
target_link_libraries(nymble_hw_interface ${catkin_LIBRARIES})

add_executable(nymble_hw_control_loop src/nymble_hw_control_loop.cpp)
target_link_libraries(nymble_hw_control_loop
  nymble_hw_interface
  generic_hw_control_loop
  ${catkin_LIBRARIES})

install(TARGETS  
        nymble_hw_interface 
        LIBRARY DESTINATION
    ${CATKIN_PACKAGE_LIB_DESTINATION})

install(TARGETS
    nymble_hw_control_loop
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(DIRECTORY include/${PROJECT_NAME}/   DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION})

On running catkin_make, I am getting the error

/usr/bin/ld: cannot find -lgeneric_hw_control_loop
collect2: error: ld returned 1 exit status
make[2]: *** [/home/rohin/catkin_ws/devel/lib/hardware/nymble_hw_control_loop] Error 1
make[1]: *** [nymblebot/hardware/CMakeFiles/nymble_hw_control_loop.dir/all] Error 2
make: *** [all] Error 2

I am at a loss to understand why my generic_hw_control_loop library is not being linked when it is an installed library under the package ros_control_boilerplate.

Also I have listed ros_control_boilerplate as a build and run dependency in my package.xml

The executable I'm building contains :

#include <ros_control_boilerplate/generic_hw_control_loop.h>
edit retag flag offensive close merge delete

2 Answers

Sort by ยป oldest newest most voted
0

answered 2016-06-25 04:52:25 -0500

rohin gravatar image

Issue solved.

I had messed some of my files. Hence catkin was looking in the wrong directory.

edit flag offensive delete link more
0

answered 2016-06-25 00:32:03 -0500

sar1994 gravatar image

can you specify the folder path where generic_hw_control_loop include files can be found. For ex. say the package include files are at /usr/include/<pakage-name> . then u need to add that "set" command in CMakelists file like the below example for instructing the compilier for including the eigen3 files. set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -march=native -Wall -std=c++0x -I/usr/include/eigen3" )

In my case it worked

edit flag offensive delete link more

Comments

Hi! Thanks for taking out your time and replying.

I tried your fix. The same error persists. Basically I'm trying to include the above mentioned file to use a class defined in it.

In my executable file:

ros_control_boilerplate::GenericHWControlLoop control_loop(nh, nymble_hw_interface);
rohin gravatar image rohin  ( 2016-06-25 01:16:23 -0500 )edit

The problem is that linker is not able to find the directory generic_hw_control_loop. So please attach the CMakelists file the path directory of the library files of the generic_hw_control_loop. One fix can be be to specify the library path(complete path) in 'include_directories()' in CMakelists fil

sar1994 gravatar image sar1994  ( 2016-06-25 01:50:39 -0500 )edit

Thanks for helping out. Path directory to the library files is:

/opt/ros/indigo/include/ros_control_boilerplate/

I've uploaded the files here.

rohin gravatar image rohin  ( 2016-06-25 02:05:23 -0500 )edit

Question Tools

1 follower

Stats

Asked: 2016-06-24 22:05:51 -0500

Seen: 3,289 times

Last updated: Jun 25 '16