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?
CMAKE_TOOLCHAIN_FILE
parameter when cross-compile your project. The toolchain shouldn't allowfind_*
commands to search things under the host. And no,/usr/share
is never a path to the libraries. Under theshare/
subdirectory the packages are usually stored their architecture-independent data. The libraries are normally contained underlib*/
subdirectory./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...