【发布时间】:2020-01-29 19:01:07
【问题描述】:
我正在尝试使用 CMake 在 macOS 上编译我的项目。我通过 brew 安装了 gstreamer,我可以访问包含目录。例如,这是 gstreamer 的包含目录:
/usr/local/Cellar/gstreamer/1.16.2/include/gstreamer-1.0/
当运行cmake 并跟随CMakeLists.txt 时,一切都运行成功,但是当我尝试链接时make 失败并出现以下错误:
[ 25%] Linking CXX executable multiviewer
ld: library not found for -lgstreamer-1.0
CMakeLists.txt:
cmake_minimum_required(VERSION 3.15)
project(application)
set(CMAKE_CXX_STANDARD 20)
set(CMAKE_AUTOMOC ON)
set(CMAKE_AUTOUIC ON)
set(CMAKE_AUTORCC ON)
find_package(Qt5Core REQUIRED)
find_package(Qt5Quick REQUIRED)
find_package(Qt5WebSockets REQUIRED)
# Required for GStreamer
find_package(PkgConfig)
# Look for GStreamer installation
pkg_check_modules(GST REQUIRED gstreamer-1.0)
add_executable(application
main.cpp qml.qrc server.cpp server.h
${PROTO_SRCS} ${PROTO_HDRS} client.cpp client.h)
# Qt5
target_link_libraries(application Qt5::Core Qt5::Quick Qt5::WebSockets)
# GStreamer
target_include_directories(application PUBLIC ${GST_INCLUDE_DIRS})
target_compile_options(application PUBLIC ${GST_CFLAGS})
target_link_libraries(application ${GST_LIBRARIES})
这是我安装的软件包:
brew install pkg-config
brew install gstreamer
brew install gst-plugins-base
brew install gst-plugins-good
brew install gst-plugins-bad
brew install gst-plugins-ugly
brew install gst-libav
pkg-config --cflags gstreamer-1.0的输出:
-I/usr/local/Cellar/libffi/3.2.1/lib/libffi-3.2.1/include -I/usr/local/Cellar/gstreamer/1.16.2/include/gstreamer-1.0 -I/usr/local/Cellar/glib/2.62.4/include -I/usr/local/Cellar/glib/2.62.4/include/glib-2.0 -I/usr/local/Cellar/glib/2.62.4/lib/glib-2.0/include -I/usr/local/opt/gettext/include -I/usr/local/Cellar/pcre/8.43/include
pkg-config --libs gstreamer-1.0 的输出:
-L/usr/local/Cellar/gstreamer/1.16.2/lib -L/usr/local/Cellar/glib/2.62.4/lib -L/usr/local/opt/gettext/lib -lgstreamer-1.0 -lgobject-2.0 -lglib-2.0 -lintl
我需要安装其他东西还是我做错了什么?
【问题讨论】:
-
GST_LIBRARIES变量的内容是什么?似乎 GStreamer 库没有被链接。试试message("GST_LIBRARIES: ${GST_LIBRARIES}") -
@squareskittles 输出为:
GST_LIBRARIES: gstreamer-1.0;gobject-2.0;glib-2.0;intl -
好的,这个问题是编译器不知道库的完整路径。如果填充正确,使用
GST_LINK_LIBRARIES变量可能会更好。 -
@squareskittles 谢谢!这就是解决方案。您可能想写一个答案,以便我可以为未来迷失的灵魂接受它
标签: macos makefile cmake homebrew gstreamer