# Include directory for other packages

I'm trying to learn how to use a package that depends on another package I have created. Both are under ros_workspace/ and one of them(first_pack) depends on the other (lib_test, which is a shared library).

I'm able to compile lib_test, and its header file is located under lib_test/include . I added <depend package="lib_test"/> in first_pack's manifest, and included the file "lib_test/mylib.h" in its executable. But when I try to compile it, it shows:

fatal error: lib_test/mylib.h: No such file or directory compilation terminated.

I tried adding: <export> <cpp cflags="-I\${prefix}/include"/>
</export>

to lib_test manifest, but it still doesn't work. What is the right way to do it?

edit retag close merge delete

Sort by » oldest newest most voted

Put your header files of lib_test in the directory lib_test/include/lib_test/. This directory is automatically exported. You should be able to include "lib_test/mylib.h" then in any package that defines the <depend ...> in its manifest.

To look for missing include and linking errors, you can use

make VERBOSE=1


to see the actual compiler command with all the includes that are defined.

more