cannot find -lMylib
I have two ROS packages. Package A loads the library Mylib, which is a .so file. package B uses package A with find packages().
Package A compiles without any issues, while package B fails for the reason: cannot find -lMylib.
I don't understand why Mylib is required by package B if Package A loaded it without problems
---EDIT----
These are the Cmake Formats packageA
cmake_minimum_required(VERSION 2.8.3)
project(PackageA)
set(CMAKE_CXX_COMPILER_ID "--with-cc=/usr/bin/mpicc --with-cxx=/usr/bin/mpicxx -lmpi_cxx")
add_compile_options(-std=c++14)
find_package(Eigen3 REQUIRED)
find_package(catkin REQUIRED COMPONENTS
roscpp
moveit_core
moveit_ros_planning
moveit_ros_planning_interface
moveit_msgs
)
catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS
message_runtime
roscpp moveit_msgs moveit_ros_planning
moveit_ros_planning_interface
moveit_core
DEPENDS
EIGEN3
)
include_directories(
include
${catkin_INCLUDE_DIRS}
lib
${EIGEN3_INCLUDE_DIRS}
)
link_directories(lib/myLibFolder/)
set(MY_LIB_NAME MyLib)
add_library(some_lib src/some_lib.cpp)
target_link_libraries(some_lib ${MY_LIB_NAME} ${catkin_LIBRARIES})
add_library(some_lib_2 src/some_lib_2.cpp)
target_link_libraries(some_lib_2 some_lib ${catkin_LIBRARIES})
add_library(packageA_launcher src/PackageA_launcher.cpp)
target_link_libraries( packageA_launcher some_lib_2 ${catkin_LIBRARIES})
packageB
cmake_minimum_required(VERSION 2.8.3)
project(PackageB)
set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++14 ")
find_package(catkin REQUIRED COMPONENTS
cmake_modules
PackageA )
find_package(Boost REQUIRED COMPONENTS system) catkin_package(
INCLUDE_DIRS
include
LIBRARIES
CATKIN_DEPENDS
DEPENDS
PackageA)
add_executable(some_PackageB_cpp
src/some_PackageB_cpp.cpp )
target_link_libraries(some_PackageB_cpp packageA_launcher ${catkin_LIBRARIES} ) }
The error comes from package B.Package A compiles.
@mgruhler How can I say
"hey package B, just link against everything that package A links against"?
just to clarify,
MyLib
is some third-party (or whatever) compiled library file (.so
, so a shared library), that you put intoPackageA/lib/myLibFolder
, right?It is not located somewhere outside of
PackageA
?@mgruhler Exactly, it's a .so file located inside PackageA