CMake Install Targets

asked 2014-04-08 11:30:07 -0500

atp gravatar image

updated 2014-04-08 11:30:37 -0500

I have a project with one executable and multiple libraries. When installing this package, I get a shared libraries error:

/opt/ros/hydro/lib/handle_detector/localization: error while loading shared libraries: libaffordances_lib.so: cannot open shared object file: No such file or directory.

Now, I have added the libraries as install targets to the CMakeLists.txt, but I'm still wondering whether it is correct.

cmake_minimum_required(VERSION 2.8.3)
project(handle_detector)

find_package(catkin REQUIRED COMPONENTS 
    eigen_conversions 
  geometry_msgs 
    message_generation 
  roscpp 
    pcl_ros
  pcl_conversions
  std_msgs 
    tf
    tf_conversions
  visualization_msgs)

find_package(LAPACK REQUIRED)

find_package(Eigen REQUIRED)
include_directories(${Eigen_INCLUDE_DIRS})

set(CMAKE_CXX_FLAGS "-DNDEBUG -O3 -fopenmp")

add_message_files(
  FILES
  CylinderMsg.msg
  CylinderArrayMsg.msg
  HandleListMsg.msg
)

generate_messages(DEPENDENCIES geometry_msgs)

catkin_package(
  LIBRARIES 
    ${PROJECT_NAME}
  CATKIN_DEPENDS 
    eigen_conversions 
    geometry_msgs 
    message_generation 
    roscpp 
    pcl_ros
    pcl_conversions
    std_msgs 
    tf
    tf_conversions
    visualization_msgs
 DEPENDS 
  Eigen
  LAPACK)

include_directories(${catkin_INCLUDE_DIRS})

add_executable(localization src/localization.cpp)

add_library(affordances_lib src/affordances.cpp)
add_library(visualizer_lib src/visualizer.cpp)
add_library(messages_lib src/messages.cpp)
add_library(cylindrical_shell_lib src/cylindrical_shell.cpp)

add_dependencies(messages_lib ${PROJECT_NAME}_gencpp)

target_link_libraries(localization ${catkin_LIBRARIES})
target_link_libraries(localization affordances_lib)
target_link_libraries(localization visualizer_lib)
target_link_libraries(localization messages_lib)

target_link_libraries(affordances_lib ${catkin_LIBRARIES})
target_link_libraries(affordances_lib cylindrical_shell_lib)
target_link_libraries(affordances_lib lapack)

target_link_libraries(messages_lib ${catkin_LIBRARIES})

install(TARGETS localization affordances_lib visualizer_lib messages_lib cylindrical_shell_lib
  ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
  RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)

install(DIRECTORY launch/
  DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}/launch)
edit retag flag offensive close merge delete

Comments

1

That looks reasonable. I would start troubleshooting by trying to confirm that all of your libraries are actually getting installed into the lib directory.

ahendrix gravatar image ahendrix  ( 2014-04-08 11:58:59 -0500 )edit

I'm wondering whether the `LIBRARIES ${PROJECT_NAME}` is actually correct in your catkin_package(..) call. You do specify a number of library targets, but none of them have the name of your project (ie: `handle_detector`).

gvdhoorn gravatar image gvdhoorn  ( 2014-04-08 21:31:21 -0500 )edit

So, e.g., the line add_library(affordances_lib src/affordances.cpp) would become add_library(${PROJECT_NAME}affordances src/affordances.cpp), right? And I would have to change all other places where this library is used in the CMakeLists.txt?

atp gravatar image atp  ( 2014-04-09 08:59:35 -0500 )edit
1

For now, I would just remove the `LIBRARIES ${PROJECT_NAME}` from your catkin_package call.

ahendrix gravatar image ahendrix  ( 2014-04-09 09:42:24 -0500 )edit

@atp: I'd follow @ahendrix advice: just remove that line for now and try to get your package working first.

gvdhoorn gravatar image gvdhoorn  ( 2014-04-11 06:48:17 -0500 )edit

I did remove it yesterday. Thanks for the advice!

atp gravatar image atp  ( 2014-04-11 08:43:25 -0500 )edit

If this is resolved for you, can you post a answer to that effect? Thanks!

William gravatar image William  ( 2014-04-21 07:45:24 -0500 )edit