Adding external c library to a ROS2 node
I am using ROS2 foxy on a headless Ubuntu 20.04.1 LTS. I would like to use an external c library(Gstreamer library) in the node C++ code.
I included the the library in the node code as follows:
extern "C" {
#include "gst/gst.h"
}
In the package.xml file I added:
<depend>libgstreamer1.0-dev</depend>
<depend>libgstreamer-plugins-base1.0-dev</depend>
And in the CMakeList.txt file I added:
find_package(PkgConfig)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0
gstreamer-app-1.0)
add_executable(server src/my_server.cpp)
ament_target_dependencies(server
rclcpp my_interfaces "${GSTREAMER}")
However, every time I run colcon build I get
fatal error: gst/gst.h: No such file or directory
5 | #include "gst/gst.h"
| ^~~~~~~~~~~
gst.h can be found in /usr/include/gstreamer-1.0/gst
How can I link against this library and what is the best practice for adding external libraries in ROS2 in general. Thanks