用于覆盆子pi的qt交叉编译:找不到GLESv2
Posted
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了用于覆盆子pi的qt交叉编译:找不到GLESv2相关的知识,希望对你有一定的参考价值。
我正在尝试为我的覆盆子pi 3计算模块编译qt 5.9
,我一直在这里主要关注在线指南(https://wiki.qt.io/RaspberryPi2EGLFS)。所以,我已经将pi系统根设置为挂载点/mnt/pi-rootfs
。我还使用脚本sysroot-relativelinks.py
将符号链接设置为相对的。
使用以下参数调用qtbase配置:
./configure -opengl es2 -device linux-rpi3-g++ -device-option
CROSS_COMPILE=/home/osboxes/Downloads/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-
-sysroot /mnt/pi-rootfs -opensource -confirm-license -optimized-qmake
-reduce-exports -release -make libs -prefix /usr/local/qt5pi
-hostprefix /usr/local/qt5pi
这配置qt但没有openGL,我有消息:
ERROR: Feature 'opengles2' was enabled, but the pre-condition 'config.win32 || (!config.watchos && !features.opengl-desktop && libs.opengl_es2)' failed.
ERROR: The OpenGL functionality tests failed!
You might need to modify the include and library search paths by editing QMAKE_INCDIR_OPENGL[_ES2],
QMAKE_LIBDIR_OPENGL[_ES2] and QMAKE_LIBS_OPENGL[_ES2] in the mkspec for your platform.
Check config.log for details.
查看配置文件,我有:
> /home/osboxes/Downloads/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ -c -march=armv8-a -mtune=cortex-a53 -mfpu=crypto-neon-fp-armv8 -mfloat-abi=hard --sysroot=/mnt/pi-rootfs --sysroot=/mnt/pi-rootfs -O2 -Wall -W -fPIC -I. -I/opt/vc/include -I/opt/vc/include/interface/vcos/pthreads -I/opt/vc/include/interface/vmcs_host/linux -I/home/osboxes/Downloads/qt5/qtbase/mkspecs/devices/linux-rpi3-g++ -o opengles2.o opengles2.cpp
> opengles2.cpp:44:25: fatal error: GLES2/gl2.h: No such file or directory
> #include <GLES2/gl2.h>
> ^
> compilation terminated.
> Makefile:179: recipe for target 'opengles2.o' failed
> make: *** [opengles2.o] Error 1
=> source failed verification.
test config.gui.libraries.opengl_es2 FAILED
因此,它没有正确设置路径,所以我编辑了mkspecs
文件为linux-rpi3-g++
。因此,该文件的相关部分如下所示:
QMAKE_LFLAGS += -Wl,-rpath-link,$$[QT_SYSROOT]/opt/vc/lib
VC_LIBRARY_PATH = /opt/vc/lib
VC_INCLUDE_PATH = /opt/vc/include
# terrible, they do not appear to resolve "=" in rpath!
VC_LINK_LINE = -L=$${VC_LIBRARY_PATH} -Wl,-rpath-link,$$[QT_SYSROOT]$${VC_LIBRARY_PATH}
QMAKE_LIBDIR_OPENGL_ES2 = =$${VC_LIBRARY_PATH}
QMAKE_LIBDIR_EGL = $$QMAKE_LIBDIR_OPENGL_ES2
QMAKE_LIBDIR_OPENVG = $$QMAKE_LIBDIR_OPENGL_ES2
QMAKE_INCDIR_EGL =
$${VC_INCLUDE_PATH}
$${VC_INCLUDE_PATH}/interface/vcos/pthreads
$${VC_INCLUDE_PATH}/interface/vmcs_host/linux
QMAKE_INCDIR_OPENGL_ES2 = $${QMAKE_INCDIR_EGL}
QMAKE_LIBS_OPENGL_ES2 = $${VC_LINK_LINE} -lGLESv2
# The official opt vc EGL references GLESv2 symbols: need to link it
QMAKE_LIBS_EGL = $${VC_LINK_LINE} -lEGL -lGLESv2
所以,我尝试了各种各样的事情,包括在各个地方添加$$[QT_SYSROOT]
前缀,例如在VC_LIBRARY_PATH
和VC_INCLUDE_PATH
,即使我得到它找到它不喜欢GLES2库的包含路径(我已经验证了libs确实在正确的位置:/mnt/pi-rootfs/opt/vc/lib
)。
我想知道是否有人建议如何在不编辑qt mkspecs文件和做其他此类黑客的情况下解决这个问题。
编辑所以,我修改了mkspecs文件如下:
QMAKE_LFLAGS += -Wl,-rpath-link,$$[QT_SYSROOT]/opt/vc/lib
VC_LIBRARY_PATH = $$[QT_SYSROOT]/opt/vc/lib # prepended
VC_INCLUDE_PATH = $$[QT_SYSROOT]/opt/vc/include #prepended
# terrible, they do not appear to resolve "=" in rpath!
VC_LINK_LINE = -L=$${VC_LIBRARY_PATH} -Wl,-rpath-link,$$[QT_SYSROOT]$${VC_LIBRARY_PATH}
QMAKE_LIBDIR_OPENGL_ES2 = =$${VC_LIBRARY_PATH}
QMAKE_LIBDIR_EGL = $$QMAKE_LIBDIR_OPENGL_ES2
QMAKE_LIBDIR_OPENVG = $$QMAKE_LIBDIR_OPENGL_ES2
QMAKE_INCDIR_EGL =
$${VC_INCLUDE_PATH}
$${VC_INCLUDE_PATH}/interface/vcos/pthreads
$${VC_INCLUDE_PATH}/interface/vmcs_host/linux
QMAKE_INCDIR_OPENGL_ES2 = $${QMAKE_INCDIR_EGL}
#QMAKE_LIBS_OPENGL_ES2 = $${VC_LINK_LINE} -lGLESv2 #original
QMAKE_LIBS_OPENGL_ES2 = -lGLESv2 #changed
# The official opt vc EGL references GLESv2 symbols: need to link it
#QMAKE_LIBS_EGL = $${VC_LINK_LINE} -lEGL -lGLESv2 #original
QMAKE_LIBS_EGL = -lEGL -lGLESv2 #changed
这会在尝试查找gles时导致链接错误:
> /home/osboxes/Downloads/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-g++ -Wl,-rpath-link,/mnt/pi-rootfs/opt/vc/lib -Wl,-rpath-link,/mnt/pi-rootfs/usr/lib/arm-linux-gnueabihf -Wl,-rpath-link,/mnt/pi-rootfs/lib/arm-linux-gnueabihf -mfloat-abi=hard --sysroot=/mnt/pi-rootfs --sysroot=/mnt/pi-rootfs -Wl,-O1 -fuse-ld=gold -o opengles2 opengles2.o -L=/mnt/pi-rootfs/opt/vc/lib -lGLESv2
> /home/osboxes/Downloads/gcc-linaro-6.3.1-2017.05-x86_64_arm-linux-gnueabihf/bin/../lib/gcc/arm-linux-gnueabihf/6.3.1/../../../../arm-linux-gnueabihf/bin/ld.gold: error: cannot find -lGLESv2
> opengles2.o:opengles2.cpp:function main: error: undefined reference to 'glUniform1f'
> opengles2.o:opengles2.cpp:function main: error: undefined reference to 'glClear'
> collect2: error: ld returned 1 exit status
> Makefile:65: recipe for target 'opengles2' failed
路径-L=/mnt/pi-rootfs/opt/vc/lib
是正确的,我验证这是glesv2库所在的位置。
这是我使用的qmake.conf(它对我有用):
include(../common/linux_device_pre.conf)
QMAKE_LFLAGS += -Wl,-rpath-link,$$[QT_SYSROOT]/opt/vc/lib
QMAKE_LFLAGS += -Wl,-rpath-link,$$[QT_SYSROOT]/home/pi/qtdeps/lib
QMAKE_LIBDIR_OPENGL_ES2 = $$[QT_SYSROOT]/opt/vc/lib
QMAKE_LIBDIR_EGL = $$QMAKE_LIBDIR_OPENGL_ES2
QMAKE_LIBDIR_OPENVG = $$QMAKE_LIBDIR_OPENGL_ES2
QMAKE_INCDIR_EGL = $$[QT_SYSROOT]/opt/vc/include
$$[QT_SYSROOT]/opt/vc/include/interface/vcos/pthreads
$$[QT_SYSROOT]/opt/vc/include/interface/vmcs_host/linux
QMAKE_INCDIR_OPENGL_ES2 = $${QMAKE_INCDIR_EGL}
QMAKE_INCDIR_OPENVG = $${QMAKE_INCDIR_EGL}
QMAKE_LIBS_EGL = -lEGL -lGLESv2
QMAKE_LIBS_OPENVG = -lEGL -lOpenVG -lGLESv2
QMAKE_CFLAGS = -march=armv8-a -mtune=cortex-a53 -mfpu=crypto-neon-fp-armv8
QMAKE_CXXFLAGS = $$QMAKE_CFLAGS
DISTRO_OPTS += hard-float
DISTRO_OPTS += deb-multi-arch
# Preferred eglfs backend
EGLFS_DEVICE_INTEGRATION= eglfs_brcm
include(../common/linux_arm_device_post.conf)
load(qt_config)
在Raspbian Stretch中,必须调用“rpi-update”,否则/ opt / vc / lib中缺少“libGLESv2.so”。这修复了链接器错误“找不到-lGLESv2”
https://www.raspberrypi.org/forums/viewtopic.php?t=191638
我的起点是2017-11-29-raspbian-stretch并使用crosstool-ng在OSX中构建我的工具链。
虽然sudo rpi-update
帮助并引入了'libGLESv2.so',但它并没有为我解决问题。该问题最终出现在QT配置中。 QT使用gcc -dumpmachine
来建立元组。对我来说,它是'arm-raspbian-linux-gnueabihf'。 QT最终在/usr/lib/arm-raspbian-linux-gnueabihf
等不存在的位置搜索库和包。 (在使用GLESv2进行编译时,它最终无法找到像'libpthread.so'这样的库。)相反,如果你看一下操作系统,正确的位置是/usr/lib/arm-linux-gnueabihf
。解决方案是修改qtbase中的'configure.pri'。
--- a/configure.pri
+++ b/configure.pri
@@ -241,7 +241,7 @@ defineReplace(qtConfFunc_licenseCheck) {
# this is meant for linux device specs only
defineTest(qtConfTest_machineTuple) {
- qtRunLoggedCommand("$$QMAKE_CXX -dumpmachine", $${1}.tuple)|return(false)
+ qtRunLoggedCommand("$$QMAKE_CXX -dumpmachine | sed 's/-raspbian//'", $${1}.tuple)|return(false)
$${1}.cache += tuple
export($${1}.cache)
return(true)
这会将元组从crosstool-ng更改为三元组。
更新。如果您使用的是crosstool-ng,则此“修复”的替代方法是使用CT_TARGET = arm-linux-gnueabihf(不是CT_TARGET_ALIAS)。
以上是关于用于覆盆子pi的qt交叉编译:找不到GLESv2的主要内容,如果未能解决你的问题,请参考以下文章
Qt Creator 在远程设备(覆盆子)上运行应用程序,但该应用程序从未显示
基于IMX53(freescale) ARM架构平台, Ubuntu20.xx版本下交叉编译Qt4.8.7
基于IMX53(freescale) ARM架构平台, Ubuntu20.xx版本下交叉编译Qt4.8.7