Error with shared objects when building from source
Hello,
I am trying to build ROS + a few packages that I created from source in a rasp3 due to this issue: https://answers.ros.org/question/3510...
I am able to compile everything. I had to explicitly describe what I wanted to install in the CMakeLists in order to be able to run everything when sourcing installed_isolated/setup.bash
.
Now I can find everything but when I run a node called obstacle_detector_single_scan
it is not finding the required shared objects, I am getting this error (I had to run with debug flag to get this error msg):
/home/gus/ros_catkin_ws/install_isolated/lib/robot_safety_collision_avoidance/obstacle_detector_single_scan: error while loading shared libraries: libobstacle_detector_core.so: cannot open shared object file: No such file or directory
The CMakeList I have is:
cmake_minimum_required(VERSION 3.5)
project(robot_safety_collision_avoidance)
## Use C++14
set(CMAKE_CXX_STANDARD 14)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
## Find catkin macros and libraries
## if COMPONENTS list like find_package(catkin REQUIRED COMPONENTS xyz)
## is used, also find other catkin packages
find_package(catkin REQUIRED COMPONENTS
geometry_msgs
roscpp
rospy
std_msgs
shape_msgs
sensor_msgs
std_srvs
roslint
)
## Find system libraries
find_package(Boost REQUIRED)
###################################
## catkin specific configuration ##
###################################
catkin_package(
INCLUDE_DIRS
include
LIBRARIES
obstacle_detector_core
CATKIN_DEPENDS
roscpp
sensor_msgs
shape_msgs
DEPENDS
)
roslint_cpp()
###########
## Build ##
###########
include_directories(
include
${catkin_INCLUDE_DIRS}
# Set because Boost is an internal dependency, not transitive.
#${Boost_INCLUDE_DIRS}
)
## Declare a cpp library
add_library(obstacle_detector_core
src/ObstacleAlgorithm.cpp
)
target_compile_features(obstacle_detector_core INTERFACE cxx_std_11)
## Declare cpp executables
add_executable(obstacle_detector
src/obstacle_detector_node.cpp
src/ObstacleDetector.cpp
)
target_compile_features(obstacle_detector INTERFACE cxx_std_11)
add_executable(obstacle_detector_single_scan
src/obstacle_detector_single_scan_node.cpp
src/ObstacleDetectorSingleScan.cpp
)
target_compile_features(obstacle_detector_single_scan INTERFACE cxx_std_11)
add_executable(collision_avoidance
src/collision_avoidance_node.cpp
src/CollisionAvoidance.cpp
)
target_compile_features(collision_avoidance INTERFACE cxx_std_11)
## Add dependencies to exported targets, like ROS msgs or srvs
add_dependencies(obstacle_detector_core
${catkin_EXPORTED_TARGETS}
)
add_dependencies(obstacle_detector
${catkin_EXPORTED_TARGETS}
)
## Specify libraries to link executable targets against
target_link_libraries(obstacle_detector_core
${catkin_LIBRARIES}
)
target_link_libraries(obstacle_detector
obstacle_detector_core
${catkin_LIBRARIES}
)
target_link_libraries(obstacle_detector_single_scan
obstacle_detector_core
${catkin_LIBRARIES}
)
target_link_libraries(collision_avoidance
${catkin_LIBRARIES}
)
##########################
## Static code analysis ##
##########################
roslint_cpp()
install(DIRECTORY
launch
config
DESTINATION ${CATKIN_PACKAGE_SHARE_DESTINATION}
)
install(TARGETS
obstacle_detector
obstacle_detector_single_scan
collision_avoidance
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
)
install(DIRECTORY
include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h" PATTERN "*.hpp" PATTERN ".svn"
EXCLUDE PATTERN ".git" EXCLUDE
)
I guess I have to add something to CMakeList in order to install the shared objects? How can I do this?