0
$\begingroup$

Rosanswers logo

Hi there, we are using the below attached CMakeLists.txt to build a simple executable. Building works OK and we can also successfully run it from the devel folder (devel/lib/lawnmower_intrudor_detector/intrudor_detector_node). However after we install the executable using the "catkin_make install" command into the install/lib/lawnmower_intrudor_detector/intrudor_detector_node, the shared libraries the executable is linking against are not found anymore:

./intrudor_detector_node: error while loading shared libraries: libpcl_common.so.1.7: cannot open shared object file: No such file or directory

We verified and the 2 executables (in devel and install) indeed have different checksums - which to the best of our knowledge should not happen, right?

Using: ROS Groovy, Ubuntu 12.04

CMakeLists.txt is below. Please note that the install macro does not work when passed in the name of the package, hence only executable.

cmake_minimum_required(VERSION 2.8.3)
project(lawnmower_intrudor_detector)

find_package(catkin REQUIRED COMPONENTS laser_geometry roscpp sensor_msgs tf)

## System dependencies are found with CMake's conventions
#find_package(PCL 1.6.1 REQUIRED)
find_package(PCL 1.7.0 REQUIRED)

catkin_package(
   INCLUDE_DIRS include
   CATKIN_DEPENDS laser_geometry roscpp sensor_msgs tf
   DEPENDS eigen
)

## Specify additional locations of header files
include_directories(include
  ${catkin_INCLUDE_DIRS} 
  ${PCL_INCLUDE_DIRS}
)

## Declare a cpp executable
add_executable(intrudor_detector_node src/intrudor_detector.cpp)

## Add dependencies to the executable
# add_dependencies(lawnmower_intrudor_detector_node ${PROJECT_NAME})

target_link_libraries(intrudor_detector_node
  ${catkin_LIBRARIES}
  ${PCL_LIBRARIES}
)

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

Update: PCL_LIBRARIES are as follows: http://pastebin.com/cWTf0cjr . The weird thing about it is that there is no semicolons delimiting the respective library.

Update 2: ldd output for both executables in devel and install workspaces as follows: http://pastebin.com/ZpQBhUdJ . In install workspace pcl_common* is not found anymore.


Originally posted by dejanpan on ROS Answers with karma: 1420 on 2013-03-10

Post score: 3


Original comments

Comment by jbohren on 2013-03-10:
Does it also not work if you cd into the build directory and run make install ?

Comment by William on 2013-03-11:
To clarify, catkin_make doesn't install the file, catkin_make just runs CMake and Make together as a convenience. You can reproduce this without catkin_make with 'mkdir build && cd build && cmake ../src -DCMAKE_INSTALL_PREFIX=../install -DCATKIN_DEVEL_PREFIX=../devel && make '

Comment by William on 2013-03-11:
These are unrelated to your question, but your CMakeLists.txt find_package(...)'s PCL but does not export it in catkin_package(...) (this may or may not be desired), and you DEPEND on eigen, but never find_package(...) it, which is likely not desired behavior.

Comment by dejanpan on 2013-03-11:
@Jon: yes, it does NOT work with cd-ing into build and running make install as well.

Comment by dejanpan on 2013-03-11:
Jon, we found out that it works if append the path to the PCL libraries before: "export LD_LIBRARY_PATH=/usr/local/lib:${LD_LIBRARY_PATH}". Note that we compilled PCL ourselves and make installed it into /usr/local.

Comment by William on 2013-03-11:
@dejanpan can you output PCL_LIBRARIES and post it here? It seems like the only way the above comment fixes it is if PCL does not return absolute path libraries.

Comment by dejanpan on 2013-03-11:
@William: I updated the question with the PCL_LIBRARIES message status. Weird thing is that the libraries are not delimited by the semicolon. Is that a problem?

Comment by William on 2013-03-11:
@dejanpan No, that is a side effect of printing a list in CMake: http://stackoverflow.com/questions/7172670/best-shortest-way-to-join-a-list-in-cmake

Comment by William on 2013-03-11:
@dejanpan Can you post the output of ldd /path/to/your/executable? (In both install and devel space for comparison)

Comment by dejanpan on 2013-03-11:
@William: See update 2. In fact the executable in install workspace does not find pcl_common library anymore.

Comment by William on 2013-03-11:
@dejanpan I don't know why that is, let me play with it for a bit, maybe I can come up with something.

Comment by dejanpan on 2013-03-11:
@William: It seems that we found the solution which by running the "sudo ldconfig" command. Now the pcl_common is found and the library correctly executed. Though we are not sure why the ldconfig would need to be run manually.

Comment by William on 2013-03-11:
@dejanpan That makes sense, that will update the ld cache. Can you answer your own question here and accept it? Thanks

Comment by dejanpan on 2013-03-11:
@William: I did. But do you happen to know if you really have to update the ldconfig manually or should there be a cronjob or anything else?

Comment by William on 2013-03-11:
@dejanpan I believe you would need to run ldconfig anytime you install libraries to /usr/lib or /usr/local/lib, this is run automatically by apt usually. So, since you manually installed PCL (I assume) then you would need to manually update the ld cache.

Comment by William on 2013-03-11:
But I am not 100% certain about that.

$\endgroup$

1 Answer 1

0
$\begingroup$

Rosanswers logo

The solution: run "sudo ldconfig" command. Now the pcl_common is found and the executable correctly executed. Though we are still not sure why the ldconfig would need to be ran manually.


Originally posted by dejanpan with karma: 1420 on 2013-03-11

This answer was ACCEPTED on the original site

Post score: 1

$\endgroup$

Your Answer

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