Hello, ROS experts.
I referenced below two link.
- [link1](https://answers.ros.org/question/231199/using-catkin-to-install-pre-made-libraries/)
- [link2](https://github.com/ros-drivers/prosilica_gige_sdk/blob/32aea9be0de7e40c647166d5f54de09948635b9f/CMakeLists.txt#L149)
On my project, there are two packages. For our convenience, I'll call these A and B project.
- A project: This project have a general library, a pre-made library. (there are two library)
- B project: This project will use two library from A project.
--> There project placed on same catkin_workspace.
> The problem is that I can't not use **pre-made library** on **B project**.
detail: I succeed it to install the pre-made library on `catkin_ws/devel/lib`. But, when I build the project B, It can not find pre-made library.
How can I fix this issue?
There is more detail on below description.
---
ProjectA, CMakeLists.txt
find_library(PreMade NAMES "caffe" PATHS "${PreMade_DIR}")
message(STATUS "${PreMade}")
find_package(catkin REQUIRED COMPONENTS
roscpp
roslib
std_msgs
interface_model
)
catkin_package(
CATKIN_DEPENDS roscpp std_msgs
LIBRARIES ${PROJECT_NAME}_lib PreMade
INCLUDE_DIRS ${PROJECT_SOURCE_DIR}/include ${PreMade_INCLUDEDIR}
)
...
add_library(PreMade EXCLUDE_FROM_ALL ${PreMade} )
add_custom_command(TARGET PreMade POST_BUILD COMMAND cp ${PreMade} ${CMAKE_LIBRARY_OUTPUT_DIRECTORY}/ )
set_target_properties(PreMade PROPERTIES LINKER_LANGUAGE CXX ``` )
install( FILES ${PreMade}
DESTINATION ${CATKIN_PACKAGE_LIB_DESTINATION})
ProjectA, CMakeLists.txt
find_package(catkin REQUIRED COMPONENTS
roscpp
std_msgs
ProjectA
)
...
add_executable(${PROJECT_NAME}_node ${SOURCES})
target_link_libraries(${PROJECT_NAME}_node
${catkin_LIBRARIES}
${OpenCV_LIBRARIES}
PreMade
)
---
**Build Log**(Catkin_make)
-- Configuring done
-- Generating done
-- Build files have been written to: /catkin_ws/build
####
#### Running command: "make -j8 -l8" in "/catkin_ws/build"
####
[ 6%] Built target Caffe
[ 26%] Built target interface_model_lib
[ 40%] Built target refine_det_lib
[ 93%] Linking CXX executable /catkin_ws/devel/lib/ProjectB/ProjectB_node
/usr/bin/ld: cannot find -lProejctA_premade_lib
collect2: error: ld returned 1 exit status
ProjectB/CMakeFiles/ProjectB_node.dir/build.make:199: recipe for target '/catkin_ws/devel/lib/ProjectB/ProjectB_node' failed
make[2]: *** [/catkin_ws/devel/lib/ProjectB/ProjectB_node] Error 1
CMakeFiles/Makefile2:1536: recipe for target 'ProjectB/CMakeFiles/ProjectB_node.dir/all' failed
make[1]: *** [ProjectB/CMakeFiles/ProjectB_node.dir/all] Error 2
Makefile:138: recipe for target 'all' failed
make: *** [all] Error 2
Invoking "make -j8 -l8" failed
---
* In catkin_ws/devel/lib
- [ProjectB]
- libGeneralForProejctA.so
- libPremade.so
↧