0

I'm attempting to compile a GStreamer plugin. I can successfully compile on linux but using the same CMakeLists.txt in the Cerbero cross-compiler fails.

CMakeLists.txt:

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

The two message lines output:

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

When I call make I get the following errors:

[ 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'
mark mcmurray
  • 1,581
  • 4
  • 18
  • 28
  • "make V=1" will probably show you the actual linker command so you could see what is wrong. I suspect using just *_INCLUDE_DIRS and *_LIBRARIES isn't enough: as an example, what about non-standard library dirs (I guess target_link_directories with "GLIB2_LIBRARY_DIRS" would work in cmake) – Jussi Kukkonen Jan 08 '20 at 13:20
  • These functions are in GObject. – Botje Jan 08 '20 at 14:34
  • Does this answer your question? [What is an undefined reference/unresolved external symbol error and how do I fix it?](https://stackoverflow.com/questions/12573816/what-is-an-undefined-reference-unresolved-external-symbol-error-and-how-do-i-fix) – Botje Jan 08 '20 at 14:35
  • It was the fact they were in GObject rather than GLib. It's now cross-compiling for android and I'm working to add it to my android app. That it builds on Linux without the GObject inclusion threw me (and is still unclear if I'm honest). – mark mcmurray Jan 08 '20 at 14:56

0 Answers0