0

i'm currently trying to port a Qmake project to Cmake. I'm facing problems including the gstreamer library through pkgconfig. My Qmake, which works, is :

INCLUDEPATH += $$PWD
DEPENDPATH += $$PWD
HEADERS += \
    $$PWD/QmlVideoPlayer.hpp
SOURCES += \
    $$PWD/private/QmlVideoPlayer.cpp
unix: CONFIG += link_pkgconfig
unix: PKGCONFIG += gstreamer-1.0
unix: PKGCONFIG += gstreamer-video-1.0

The cmake seems like:

find_package(PkgConfig REQUIRED)
find_package(Qt5 COMPONENTS Core Gui Quick Widgets REQUIRED)
if(NOT PKG_CONFIG_FOUND)
  message(FATAL_ERROR "pkg-config not found!" )
endif()
pkg_check_modules(GST REQUIRED gstreamer-1.0 gstreamer-video-1.0)
include_directories(${GST_INCLUDE_DIRS})
link_directories(${GST_LIBRARY_DIRS})
add_definitions(${GST_CFLAGS_OTHER})
add_library(qmlvideoplayer
    QmlVideoPlayer.hpp
    private/QmlVideoPlayer.cpp
)
target_link_libraries(qmlvideoplayer
    PRIVATE Qt5::Core Qt5::Gui Qt5::Quick Qt5::Widgets
    PUBLIC ${GST_LIBRARIES})

The build works fine if deployed locally, but when i try to deploy in an external board (Linux OS) it trhows the following errors:

error: WARNING: unsafe header/library path used in cross-compilation: '-I/usr/include/gstreamer-1.0'
error: WARNING: unsafe header/library path used in cross-compilation: '-I/usr/include/glib-2.0'
error: WARNING: unsafe header/library path used in cross-compilation: '-I/usr/lib/glib-2.0/include'
error: glibconfig.h: No such file or directory
error: ninja: build stopped: subcommand failed.

The libraries path in the external board is:

root@test:/usr/share# ls
alsa              fontconfig        gst-plugins-base  sounds
dhcpcd            fonts             gstreamer-1.0     terminfo
drirc.d           gettext           icons             udhcpc
ffmpeg            glib-2.0          locale            xml

Any idea about how to accomplish this porting?

13
  • 1
    Something wrong in your toolchain file which you pass to CMake via CMAKE_TOOLCHAIN_FILE parameter when cross-compile your project. The toolchain shouldn't allow find_* commands to search things under the host. And no, /usr/share is never a path to the libraries. Under the share/ subdirectory the packages are usually stored their architecture-independent data. The libraries are normally contained under lib*/ subdirectory.
    – Tsyvarev
    Commented Apr 19, 2023 at 14:51
  • Hi, thank you for your answer. The libraries I need are not found in lib subdirectory. I cannot modify the bsp, and so, the location of the library. I haven't specified the path of the toolchain file anywhere, so where can I find it and where can I put it? Also, I've never specified such file with QMake and everything was working fine.
    – mungimatte
    Commented Apr 19, 2023 at 15:33
  • 1
    The link in my previous comment contains many information about what a toolchain file is and how to write it. Cross-compiling without a toolchain file is wrong: stackoverflow.com/a/63944545/3440745
    – Tsyvarev
    Commented Apr 19, 2023 at 16:20
  • I've said something wrong in the previous comment, actually i'm compiling through QTCreator which creates an integrated toolchain at build phase. But to me, is not clear how to specify where to look for the libraries. Just to be clear the libraries are located in /usr/lib.
    – mungimatte
    Commented Apr 20, 2023 at 10:15
  • "Just to be clear the libraries are located in /usr/lib" - But you have the clear warning that paths from /usr/lib shouldn't be used for cross-compilation: unsafe header/library path used in cross-compilation: '-I/usr/lib/glib-2.0/include'. It seems you don't quite understand what you are doing...
    – Tsyvarev
    Commented Apr 20, 2023 at 10:46

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.