Depend on package built in workspace
I have a driver package_a
and I want modify its dependency package_b
for use in my project. I downloaded the package_b
source into my catkin workspace, made the modifications, and successfully built the dependency. However package_a
is unable to reference the new changes. I think is is because CMake found a different version of package_b
somewhere else which does not have my modifications. How should I modify my CMakeLists.txt to use the locally build package_b
in the catkin ws? I run rospack find package_b
and the path is catkin_ws/src/package_b
.
/catkin_ws
- /src
- /package_a
- CMakeLists.txt
- package.xml
- /package_b
- CMakeLists.txt
- package.xml
The dependencies listed in package_a/CMakeLists.txt
is
find_package(package_b REQUIRED)
find_package(catkin REQUIRED COMPONENTS ...)
catkin_package(
INCLUDE_DIRS include
CATKIN_DEPENDS
...
DEPENDS package_b
)
include_directories(
include
${package_b_INCLUDE_DIRS}
${catkin_INCLUDE_DIRS}
)
target_link_libraries(${PROJECT_NAME}
${package_b_LIBRARIES}
${catkin_LIBRARIES}
)
For reference, the package_b
is libcreate and package_a
is create_robot.
CMakeLists reads ok. Also 'rospack find package_b' command is also outputing correct path. Are you installing the resultant library?
Is
package_b
a ROS package? If yes, you should probably have it in thefind_package(catkin...)
command as a component, as well as inCATKIN_DEPENDS
instead ofDEPENDS
. Also, how exactly do you addpackage_b
to theinclude_Directories
andtarget_link_libraries
calls? Please edit your question with the relevant lines of yourCMakeLIsts.txt
.After running catkin_make at least once, have you sourced the setup.bash in
catkin_ws/devel
?You have to do this for catkin_make to "see" the packages in your home directory.
@prince I am not sure if I am creating an install for
package_b
.@mgruhler
package_b
is a ROS package and I have thepackage_b.so
library in my/opt/ros/melodic/lib
folder. I added theinlcude_directories
andtarget_link_libraries
to the posted question.@Mike Scheutzow The build itself is failing, so sourcing the workspace would not solve the issue.
@bscout2011 I'm assuming you followed the build instructions in
libcreate
s Readme and usedcatkin_tools
to build it? With a plaincatkin_make
the lib shouldn't compile. This is becauselibcreate
is actually not a ROS package, but a plain CMake project (even though thepackage.xml
exists), but theCMakeLIsts.txt
does notfind_package(catkin ...)
.If you used
catkin_tools
, you actually need to source the workspace once again for the package path to be picked up. This is becausecatkin_tools
by default builds the packages in isolation (same holds forcatkin_make_isolated
).@mgruhler you should post your comment as the answer.