Can't find library added to a ros pkg which itself is linked to another ros pkg
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?