6

I'm trying to build a C++ application with gstreamer using CMake. In my CMakeLists.txt file, gstreamer is included with the following lines:

find_package(PkgConfig REQUIRED)

pkg_search_module(GST REQUIRED gstreamer-1.0>=1.4
    gstreamer-sdp-1.0>=1.4
    gstreamer-video-1.0>=1.4
    gstreamer-app-1.0>=1.4)

I can run cmake without any errors, but make gives the following error:

fatal error: gst/gst.h: No such file or directory

Gstreamer is installed and I have checked that the gst.h file is located at /usr/include/gstreamer-1.0/gst/gst.h along with the other gstreamer header files.

The following environment variables has been set:

export PKG_CONFIG_PATH=/opt/qt-5.9.1/lib/pkgconfig
export LD_LIBRARY_PATH=/opt/qt-5.9.1/lib
export GST_PLUGIN_PATH=/usr/include/gstreamer-1.0

I've also checked the output from pkg-config, suggested in another post with similar problem:

$ pkg-config --cflags gstreamer-1.0
-pthread -I/usr/include/gstreamer-1.0 -I/usr/lib/x86_64-linux-gnu/gstreamer-1.0/include -I/usr/include/glib-2.0 -I/usr/x86_64-linux-gnu/glib-2.0/include

So why can't the gstreamer header file be found?

(I'm new to both gstreamer and CMake)

KMK
  • 1,439
  • 5
  • 21
  • 39
  • 1
    `pkg_search_module` sets variables which contains include directories and other things about the libraries. Have you used these variable in your `CMakeLists.txt`? See [that my post](https://stackoverflow.com/questions/35457533/findpkgconfig-with-set-target-properties-is-unusable-for-setting-cflags-ldflags/35476270#35476270) about usage of pkg-config variables in CMake. – Tsyvarev Nov 20 '17 at 09:16

1 Answers1

9

Turns out I didn't actually link the libraries to the application. Adding the following 2 lines to the CMakeLists.txt fixed the error (in case anyone else makes the same mistake as me):

target_include_directories(videoDemo PRIVATE ${GST_INCLUDE_DIRS})
target_link_libraries(videoDemo ${GST_LIBRARIES})

(videoDemo is the name of the application)

KMK
  • 1,439
  • 5
  • 21
  • 39