Ask Your Question
1

Can't find library added to a ros pkg which itself is linked to another ros pkg

asked 2020-07-24 07:59:58 -0500

madmax gravatar image

updated 2020-07-24 08:01:23 -0500

I have a ros library called common which has a dependency on a non ros library ext_lib.
Then I have another ros library in another ros pkg which links to common.
If I compile that with eloquent, everything is fine but with foxy it says: /usr/bin/ld: cannot find -lext_lib

common lib cmake:

add_library(ext_lib SHARED IMPORTED)
set_target_properties(ext_lib PROPERTIES IMPORTED_LOCATION $ENV{PROJECT_DIR}/install/lib/ext_lib.so)   

add_library(common)  
target_link_libraries(common ext_lib)  
target_include_directories(common PUBLIC
  $<BUILD_INTERFACE:${CMAKE_CURRENT_SOURCE_DIR}/include>
  $<INSTALL_INTERFACE:include>)
ament_target_dependencies(
  common
  ${DEPS}
)

install(
  TARGETS common
  EXPORT export_common
  ARCHIVE DESTINATION lib
  LIBRARY DESTINATION lib
  RUNTIME DESTINATION bin
)  

ament_export_targets(
  export_common
)
ament_export_libraries(
        ext_lib
)
ament_export_dependencies(${DEPS})

ament_package()

another pkg linking to common:

add_library(${PROJECT_NAME} SHARED
  src/robot.cpp
)

ament_target_dependencies(${PROJECT_NAME}
  rclcpp
  common
)

ament_export_include_directories(include)
ament_export_libraries(${PROJECT_NAME})
ament_package()

How do you link to an imported library?

edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted
0

answered 2020-07-24 12:31:20 -0500

QuentinT gravatar image

I think you are missing ext_lib in your ament_export_dependencies() call in your library's cmake file

edit flag offensive delete link more

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

2 followers

Stats

Asked: 2020-07-24 07:59:58 -0500

Seen: 52 times

Last updated: Jul 24 '20