Laurent Loots
Laurent Loots

Reputation: 145

gstreamer not found by CLion on Ubuntu 16.04 LTS

I'm working on a project that requires gstreamer to stream a webcam feed over UPD to another computer. I've been trying all morning to get gstreamer installed on my Ubuntu 16.04, eventually I managed to get it working using the following command:

sudo apt-get install libgstreamer0.10-dev libgstreamer0.10-0-dbg libgstreamer0.10-0 gstreamer0.10-tools gstreamer-tools gstreamer0.10-doc gstreamer0.10-x

I also modified my cmake file in my project in an attempt to get the gstreamer library included (see comments):

cmake_minimum_required(VERSION 3.1.0)

PROJECT(gstreamer-test)

# paths
LINK_DIRECTORIES(/usr/local/lib)            # OpenCV
LINK_DIRECTORIES(/usr/include/glib-2.0)     #gstreamer
LINK_DIRECTORIES(/usr/include/gstreamer-0.10) 

# Build settings
SET(EXECUTABLE_OUTPUT_PATH build/bin)
SET(LIBRARY_OUTPUT_PATH build/lib)
SET(CMAKE_RUNTIME_OUTPUT_DIRECTORY build)


# Compiler settings
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -std=c++11")


SET(OpenCV_LIBRARIES opencv_core opencv_highgui opencv_videoio -lopencv_calib3d opencv_imgproc -lopencv_imgcodecs opencv_ml opencv_objdetect opencv_features2d opencv_flann)


add_executable(gstreamer_test main.cpp)
TARGET_LINK_LIBRARIES(gstreamer_test ${OpenCV_LIBRARIES})

Still, CLion refuses to include gstreamer. When I try to build the tutorial 'hello world' application from their website (https://gstreamer.freedesktop.org/documentation/application-development/basics/helloworld.html), it fails because CLion cannot find the included gst/gst.h and glib.h files.

Some fora suggest using the find_package command, but I'm not even sure what the exact package name of this library is, I only know the location of the header files. Documentation about this seems to be scarce too.

Does anyone have an idea how to correctly include the gstreamer library in my project?

Upvotes: 2

Views: 2478

Answers (2)

fandyushin
fandyushin

Reputation: 2432

Try find_package. You can take this module https://github.com/WebKit/webkit/blob/master/Source/cmake/FindGStreamer.cmake and put it e.g in ./cmake/ . Than add to your CMakeLists.txt

set(CMAKE_MODULE_PATH ${CMAKE_SOURCE_DIR}/cmake/)

find_package(GStreamer)
if(GStreamer_FOUND)
  message(STATUS "FOUND!!")
  include_directories(${GSTREAMER_INCLUDE_DIRS})
endif()
...
target_link_libraries(gstreamer_test ${GSTREAMER_LIBRARIES})

My CMake output:

-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.1") 
-- Checking for module 'gstreamer-1.0 >= '
--   Found gstreamer-1.0 , version 1.8.3
-- Checking for module 'gstreamer-base-1.0 >= '
--   Found gstreamer-base-1.0 , version 1.8.3
-- Checking for module 'gstreamer-app-1.0 >= '
--   
-- Checking for module 'gstreamer-audio-1.0 >= '

And variables in CMakeCache:

//Path to a library.
GSTREAMER_LIBRARIES:FILEPATH=/usr/lib/x86_64-linux-gnu/libgstreamer-1.0.so

Upvotes: 1

c4pQ
c4pQ

Reputation: 968

Just use INCLUDE_DIRECTORIES instead of LINK_DIRECTORIES

  • The first stands for -I compiler option (where to find headers).
  • The second - -L (where to find libraries).

As you understand it's different things.

Upvotes: 1

Related Questions