rayvburn / hubero

HuBeRo - a Framework to Simulate Human Behaviour in Robot Research
https://github.com/rayvburn/hubero
BSD 3-Clause "New" or "Revised" License
3 stars 0 forks source link

`hubero_bringup_gazebo_ros` cannot find library built by `hubero_gazebo` #46

Closed rayvburn closed 2 years ago

rayvburn commented 2 years ago

This error happens when hubero_bringup_gazebo_ros/CMakeLists.txt tries to find hubero_gazebo package:

find_package(catkin REQUIRED COMPONENTS
  hubero_gazebo
  hubero_ros
)

Build error descrption:

CMake Error at <PATH_TO_WORKSPACE>/devel/share/hubero_gazebo/cmake/hubero_gazeboConfig.cmake:173 (message):
  Project 'hubero_bringup_gazebo_ros' tried to find library
  'hubero_gazebo_actor'.  The library is neither a target nor built/installed
  properly.  Did you compile project 'hubero_gazebo'? Did you find_package()
  it before the subdirectory containing its code is included?
Call Stack (most recent call first):
  /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package)
  CMakeLists.txt:9 (find_package)

In fact libhubero_gazebo_actor.so is generated, but is located in src/hubero/hubero_gazebo/lib directory. The problem is that I could not manage to add this directory to hubero_gazebo_LIBRARY_DIRS.

I've tried to put into hubero_gazebo/CMakeLists.txt:

link_directories(${CMAKE_SOURCE_DIR}/lib)
set(CMAKE_PREFIX_PATH "${CMAKE_PREFIX_PATH} ${CMAKE_SOURCE_DIR}/lib")
set(CMAKE_LIBRARY_PATH "${CMAKE_LIBRARY_PATH} ${CMAKE_SOURCE_DIR}/lib")

and then in hubero_bringup_gazebo_ros/CMakeLists.txt:

find_package(catkin REQUIRED COMPONENTS
  hubero_gazebo
  hubero_ros
)
# ...
link_directories(${hubero_gazebo_LIBRARY_DIRS})

and hubero_bringup_gazebo_ros/package.xml:

  <build_depend>hubero_gazebo</build_depend>
  <build_depend>hubero_ros</build_depend>

did not help.

Note that .so file path relative to package src is needed to extend GAZEBO_PLUGIN_PATH env variable. So it's not handy to export the library somewhere into devel/.private/....

Possible workaround: PAL, for example, do not place any packages to be found in CMakeLists example. Then, there is no need to find libraries, but lack of any package is detected when trying to launch an executable.

rayvburn commented 2 years ago

Seems that devel/lib gets added to LD_LIBRARY_PATH (https://github.com/ros-simulation/gazebo_ros_pkgs/pull/923) and this is where libhubero_gazebo_actor.so would be exported normally, without:

set_target_properties(${ACTOR_PLUGIN_LIB_NAME} PROPERTIES
    LIBRARY_OUTPUT_DIRECTORY ${CMAKE_SOURCE_DIR}/lib
)

in hubero_gazebo/CMakeLists.txt. Deletion of additional target properties would allow to maintain current hubero_bringup_gazebo_ros/CMakeLists.txt.