c++ - CLion 在 Ubuntu 16.04 LTS 上未找到 gstreamer

标签 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 ) 构建教程“hello world”应用程序时,它失败了,因为 CLion 找不到包含的 gst/gst.h 和 glib.h 文件。

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

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

最佳答案

尝试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

关于c++ - CLion 在 Ubuntu 16.04 LTS 上未找到 gstreamer,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42531802/

相关文章:

mysql - xampp 无法在 ubuntu 12.04 中启动?

qt - 为什么 cmake 不移动我的 Q_OBJECT header ?

sql - 如何配置 CMake 目标或命令来预处理 C 文件?

c++ - CMake:有没有办法将选项传递给 g++ 但不传递给 nvcc

c++ - 我的代码可以在笔记本电脑上的VS代码或任何其他IDE上正常运行,但在在线IDE上却出现SIGABRT错误

xcode - 我可以在 ubuntu 中安装 xcode 吗?

C++请求(blank)中的成员(blank),调用方法时为非类类型(blank)

ubuntu - 用于动态创建虚拟网络接口(interface)的 Bash 脚本

c++ -/usr/bin/ld : error: cannot find -lboost_unit_test_framework

c++ - char数组编译错误