Still cannot include library to package from another package
Hi all,
I want to use several libraries created in one package, let say package A
, into package B
. Both packages' bareboned CMakeLists look like this:
A
: The package in which my custom libraries reside:
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(A)
catkin_package(
INCLUDE_DIRS include
LIBRARIES killer_utils_lib
haha_lib
CATKIN_DEPENDS ... <-- just a simplification
DEPENDS ...
}
include_directories(
include
${catkin_INCLUDE_DIRS}
)
add_library(killer_utils_lib src/killer_utils.cpp )
add_library(haha_lib src/haha.cpp)
target_link_libraries(killer_utils_lib
${catkin_LIBRARIES}
)
target_link_libraries(haha_lib
${catkin_LIBRARIES}
)
install(TARGETS
killer_utils_lib
haha_lib
ARCHIVE DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
LIBRARY DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION}
RUNTIME DESTINATION ${CATKIN_PACKAGE_BIN_DESTINATION}
PUBLIC_HEADER DESTINATION ${CMAKE_INSTALL_INCLUDEDIR}
)
install(DIRECTORY include/${PROJECT_NAME}/
DESTINATION ${CATKIN_PACKAGE_INCLUDE_DESTINATION}
FILES_MATCHING PATTERN "*.h"
PATTERN ".svn" EXCLUDE
)
B
: The package to which I want to import my custom libraries
CMakeLists.txt
cmake_minimum_required(VERSION 2.8.3)
project(B)
find_package(catkin REQUIRED COMPONENTS
...
killer_utils_lib
haha_lib
)
catkin_package(
INCLUDE_DIRS include
...
)
include_directories(include)
include_directories(
${catkin_INCLUDE_DIRS}
${killer_utils_lib_INCLUDE_DIRS}
${haha_lib_INCLUDE_DIRS}
)
add_executable(example src/example.cpp)
target_link_libraries(example ${catkin_LIBRARIES} killer_utils_lib haha_lib)
package.xml in B
<build_depend>killer_utils_lib</build_depend>
<build_depend>haha_lib</build_depend>
If I put these two files to compile, The following error messages will pop up:
CMake Warning at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:76 (find_package):
Could not find a package configuration file provided by "killers_utils_lib"
with any of the following names:
killer_utils_libConfig.cmake
killer_utils_lib-config.cmake
Add the installation prefix of "killer_utils_lib" to CMAKE_PREFIX_PATH or
set "killer_utils_lib_DIR" to a directory containing one of the above
files. If "killer_utils_lib" provides a separate development package or
SDK, be sure it has been installed.
Call Stack (most recent call first):
task/decision_tasks/CMakeLists.txt:7 (find_package)
-- Could not find the required component 'killer_utils_lib'. The following CMake error indicates that you either need to install the package with the same name or change your environment so that it can be found.
CMake Error at /opt/ros/kinetic/share/catkin/cmake/catkinConfig.cmake:83 (find_package):
Could not find a package configuration file provided by "killer_utils_lib"
with any of the following names:
killer_utils_libConfig.cmake
killer_utils_lib-config.cmake
Add the installation prefix of "killer_utils_lib" to CMAKE_PREFIX_PATH or
set "killer_utils_lib_DIR" to a directory containing one of the above
files. If "killer_utils_lib" provides a separate development package or
SDK, be sure it has been installed.
My question is, I've followed the steps as given in this ROS Answer article, why do my custom shared libraries killer_utils_lib
and haha_lib
still not be seen by other packages?