C++ 使用Cerbero交叉编译CMake项目以构建GStreamer插件时,未能正确链接glib-2.0
我正在尝试编译一个GStreamer插件。我可以在linux上成功编译,但在Cerbero交叉编译器中使用相同的CMakeLists.txt失败 CMakeLists.txt:C++ 使用Cerbero交叉编译CMake项目以构建GStreamer插件时,未能正确链接glib-2.0,c++,cmake,cross-compiling,gstreamer,glib,C++,Cmake,Cross Compiling,Gstreamer,Glib,我正在尝试编译一个GStreamer插件。我可以在linux上成功编译,但在Cerbero交叉编译器中使用相同的CMakeLists.txt失败 CMakeLists.txt: project(gst-plugin) cmake_minimum_required(VERSION 3.13) set(TARGET_NAME "gstplugin") find_package(GStreamer REQUIRED) find_package(PkgConfig REQUIRED) pkg_chec
project(gst-plugin)
cmake_minimum_required(VERSION 3.13)
set(TARGET_NAME "gstplugin")
find_package(GStreamer REQUIRED)
find_package(PkgConfig REQUIRED)
pkg_check_modules(GLIB2 glib-2.0 REQUIRED)
message(glib include dirs: "${GLIB2_INCLUDE_DIRS}")
message(glib libs: "${GLIB2_LIBRARIES}")
file(GLOB MAIN_SRC
${CMAKE_CURRENT_SOURCE_DIR}/*.c
${CMAKE_CURRENT_SOURCE_DIR}/*.cpp
)
file(GLOB MAIN_HEADERS
${CMAKE_CURRENT_SOURCE_DIR}/*.h
)
add_library(${TARGET_NAME} SHARED ${MAIN_SRC} ${MAIN_HEADERS})
target_include_directories(${TARGET_NAME}
PUBLIC
${GSTREAMER_INCLUDE_DIRS}
${GSTREAMER_BASE_INCLUDE_DIRS}
${GLIB2_INCLUDE_DIRS}
${CMAKE_CURRENT_SOURCE_DIR}
)
target_link_libraries(${TARGET_NAME}
PUBLIC
${GSTREAMER_LIBRARIES}
${GSTREAMER_BASE_LIBRARIES}
${GSTREAMER_VIDEO_LIBRARIES}
${GLIB2_LIBRARIES}
)
这两条消息行输出:
glibincludedirs:/home/cerbero/build/dist/android_armv7/include/glib-2.0;/home/cerbero/build/dist/android_armv7/lib/glib-2.0/include
gliblibs:glib-2.0;intl
当我调用make时,会出现以下错误:
[ 50%] Linking CXX shared library libgstplugin.so
/home/git/gstplugin/gstplugin.cpp:96: error: undefined reference to 'g_type_register_static_simple'
/home/git/gstplugin/gstplugin.cpp:96: error: undefined reference to 'g_type_class_peek_parent'
/home/git/gstplugin/gstplugin.cpp:96: error: undefined reference to 'g_type_class_adjust_private_offset'
/home/git/gstplugin/gstplugin.cpp:104: error: undefined reference to 'g_type_check_class_cast'
/home/git/gstplugin/gstplugin.cpp:132: error: undefined reference to 'g_type_check_instance_cast'
/home/git/gstplugin/gstplugin.cpp:133: error: undefined reference to 'g_type_check_instance_cast'
/home/git/gstplugin/gstplugin.cpp:141: error: undefined reference to 'g_type_check_instance_cast'
/home/git/gstplugin/gstplugin.cpp:148: error: undefined reference to 'g_type_check_class_cast'
/home/git/gstplugin/gstplugin.cpp:153: error: undefined reference to 'g_type_check_instance_cast'
/home/git/gstplugin/gstplugin.cpp:163: error: undefined reference to 'g_type_check_class_cast'
/home/git/gstplugin/gstplugin.cpp:438: error: undefined reference to 'g_type_check_class_cast'
“makev=1”可能会向您显示实际的链接器命令,以便您可以看到错误所在。我怀疑仅仅使用*_INCLUDE_DIRS和*_库是不够的:例如,非标准库DIRS(我猜带有“GLIB2_library_DIRS”的target_link_目录在cmake中可以工作)这些函数在GObject中。这是否回答了您的问题?事实上,他们是在讲戈宾特而不是油嘴滑舌。它现在是为android交叉编译的,我正在努力将它添加到我的android应用程序中。它是在Linux上构建的,没有包含GObject,这让我很困惑(我是否诚实,现在还不清楚)。