使用 cmakelists 构建 gstreamer 插件

问题描述 投票:0回答:1

我从

gstreamer
库复制了三个文件以便稍后修改。这些文件形成
plugin
并使用
OpenCV
处理来自
gstreamer
管道的帧。我稍后的目标是修改该
OpenCV
函数。问题是我无法编译包:

└── gstreamer-filter
    ├── build
    ├── CMakeLists.txt
    ├── gstcvequalizehist.cpp
    ├── include
    │   ├── gstcvequalizehist.h
    │   └── gstopencvvideofilter.h
    └── main.cpp

您可以在

gstreamer
github上找到这三个文件:

gstcvequalizehist.cpp gstcvequalizehist.h

这是我为此写的

CMakeLists

cmake_minimum_required(VERSION 3.10)

project(VideoFilter)

find_package(OpenCV REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GSTREAMER REQUIRED gstreamer-1.0)
pkg_check_modules(GST_APP REQUIRED gstreamer-app-1.0)

include_directories(include)
include_directories(${OpenCV_INCLUDE_DIRS})
include_directories(${GSTREAMER_INCLUDE_DIRS})
include_directories(${GST_APP_INCLUDE_DIRS})
include_directories(${GST_OPENCV_INCLUDE_DIRS})
link_directories(${GST_OPENCV_LIBRARY_DIRS})


# Link directories
link_directories(${OpenCV_LIBRARY_DIRS})
link_directories(${GSTREAMER_LIBRARY_DIRS})
link_directories(${GST_APP_LIBRARY_DIRS})

add_executable(VideoFilter main.cpp gstcvequalizehist.cpp)

target_link_libraries(VideoFilter ${GSTREAMER_LIBRARIES} ${GST_APP_LIBRARIES} ${OpenCV_LIBRARIES} ${GST_OPENCV_LIBRARIES})

以下是

cmake
命令的输出:

-- The C compiler identification is GNU 11.4.0
-- The CXX compiler identification is GNU 11.4.0
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Check for working C compiler: /usr/bin/cc - skipped
-- Detecting C compile features
-- Detecting C compile features - done
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Check for working CXX compiler: /usr/bin/c++ - skipped
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Warning (dev) at /usr/local/lib/cmake/opencv4/OpenCVConfig.cmake:86 (find_package):
  Policy CMP0146 is not set: The FindCUDA module is removed.  Run "cmake
  --help-policy CMP0146" for policy details.  Use the cmake_policy command to
  set the policy and suppress this warning.

Call Stack (most recent call first):
  /usr/local/lib/cmake/opencv4/OpenCVConfig.cmake:108 (find_host_package)
  CMakeLists.txt:7 (find_package)
This warning is for project developers.  Use -Wno-dev to suppress it.

-- Performing Test CMAKE_HAVE_LIBC_PTHREAD
-- Performing Test CMAKE_HAVE_LIBC_PTHREAD - Success
-- Found Threads: TRUE  
-- Found CUDA: /usr/local/cuda (found suitable exact version "12.1") 
-- Found OpenCV: /usr/local (found version "4.7.0") 
-- Found PkgConfig: /usr/bin/pkg-config (found version "0.29.2") 
-- Checking for module 'gstreamer-1.0'
--   Found gstreamer-1.0, version 1.20.3
-- Checking for module 'gstreamer-app-1.0'
--   Found gstreamer-app-1.0, version 1.20.1
-- Configuring done (1.0s)
-- Generating done (0.0s)
-- Build files have been written to: gstreamer-filter/build
[ 33%] Building CXX object CMakeFiles/VideoFilter.dir/main.cpp.o
[ 66%] Building CXX object CMakeFiles/VideoFilter.dir/gstcvequalizehist.cpp.o
[100%] Linking CXX executable VideoFilter
/usr/bin/ld: CMakeFiles/VideoFilter.dir/gstcvequalizehist.cpp.o: in function `gst_cv_equalize_hist_get_type_once()':
gstcvequalizehist.cpp:(.text+0x10a): undefined reference to `gst_opencv_video_filter_get_type'
/usr/bin/ld: CMakeFiles/VideoFilter.dir/gstcvequalizehist.cpp.o: in function `gst_cv_equalize_hist_init(_GstCvEqualizeHist*)':
gstcvequalizehist.cpp:(.text+0x26f): undefined reference to `gst_opencv_video_filter_set_in_place'
collect2: error: ld returned 1 exit status
make[2]: *** [CMakeFiles/VideoFilter.dir/build.make:182: VideoFilter] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/VideoFilter.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

看起来我没有链接某些文件或包,但我不知道它们是什么!

我使用的是 ubuntu 22.04。

c++ cmake gstreamer
1个回答
0
投票

我有两个问题。第一个与设置

GST_PLUGIN_PATH
有关,第二个是
target_link_libraries
我的可执行文件到正确的库,即 gstopencv-1.0

对于任何感兴趣的人,我在 github 上分享了一个工作示例:LINK

© www.soinside.com 2019 - 2024. All rights reserved.