CLION在Ubuntu 16.04 LTS上找不到gstreamer

时间:2017-03-01 12:30:58

标签: c++ ubuntu cmake gstreamer clion

我正在开发一个项目,该项目需要gstreamer将UPD上的网络摄像头源流式传输到另一台计算机。我整个上午都在尝试在我的Ubuntu 16.04上安装gstreamer,最终我设法使用以下命令使其工作:

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

我还在我的项目中修改了我的cmake文件,试图包含gstreamer库(参见注释):

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})

仍然,CLion拒绝包括gstreamer。当我尝试构建教程时,你好世界'从他们的网站(https://gstreamer.freedesktop.org/documentation/application-development/basics/helloworld.html)申请,它失败了,因为CLion找不到包含的gst / gst.h和glib.h文件。

有些论坛建议使用find_package命令,但我甚至不确定这个库的确切包名是什么,我只知道头文件的位置。关于此的文档似乎也很少。

有没有人知道如何在我的项目中正确包含gstreamer库?

2 个答案:

答案 0 :(得分:1)

试试find_package。您可以使用此模块https://github.com/WebKit/webkit/blob/master/Source/cmake/FindGStreamer.cmake并将其放在./cmake/中。然后添加到您的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})

我的CMake输出:

-- 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 >= '

CMakeCache中的变量:

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

答案 1 :(得分:1)

只需使用INCLUDE_DIRECTORIES代替LINK_DIRECTORIES

  • 第一个代表-I编译器选项(在哪里查找标题)。
  • 第二个 - -L(在哪里可以找到图书馆)。

正如你所理解的那样,它是不同的东西。