使用 MinGW-64 构建 Qt 5.15.2:构建错误(缺少 EGL/egl.h)

Building Qt 5.15.2 using MinGW-64: Build Error (missing EGL/egl.h)

几天来我一直在尝试构建 Qt 5.15.2。我解决了几个问题,但我找不到太多关于最后一个错误(或已过时)的信息。

配置成功但使用 mingw32-make 命令构建失败并出现此错误:

qwindowseglcontext.h: 45: 10: fatal error: EGL / egl.h: No such file or directory

我知道它缺少 header,但我找不到关于如何更正此问题的可行解释。经过一些研究,我遇到了 https://cn.khronos.org/egl/ 但下载 link 已经死了,我还看到有人说可以使用 OpenGL ES AMD SDK,但我不知道它到底是什么。

如果有人能帮我解决这个问题,那将不胜感激。谢谢

这是我在编译前用于配置 Qt 的参数列表:

./configure.bat -skip qtimageformats -skip qtwinextras -no-feature-action -no-feature-animation -no-feature-big_codecs -no-feature-buttongroup -no-feature-calendarwidget -no-feature-codecs -no-feature-colordialog -no-feature-columnview -no-feature-combobox -no-feature-commandlinkbutton -no-feature-completer -no-feature-concatenatetablesproxymodel -no-feature-contextmenu -no-feature-cups -no-feature-cupsjobwidget -no-feature-datetimeedit -no-feature-dbus -no-feature-debug -no-feature-debug_and_release -no-feature-developer-build -no-feature-dial -no-feature-dirmodel -no-feature-dockwidget -no-feature-draganddrop -no-feature-easingcurve -no-feature-effects -no-feature-errormessage -no-feature-filedialog -feature-filesystemmodel -feature-filesystemwatcher -no-feature-fontcombobox -no-feature-fontdialog -no-feature-force_debug_info -no-feature-fscompleter -no-feature-gestures -no-feature-graphicseffect -no-feature-graphicsview -no-feature-groupbox -no-feature-hijricalendar -no-feature-iconv -no-feature-icu -no-feature-identityproxymodel -no-feature-im -no-feature-image_heuristic_mask -no-feature-image_text -no-feature-imageformat_bmp -no-feature-imageformat_jpeg -no-feature-imageformat_ppm -no-feature-imageformat_xbm -no-feature-inotify -no-feature-inputdialog -no-feature-islamiccivilcalendar -no-feature-itemviews -no-feature-jalalicalendar -no-feature-keysequenceedit -no-feature-lcdnumber -no-feature-lineedit -no-feature-listview -no-feature-listwidget -no-feature-mainwindow -no-feature-mdiarea -no-feature-menu -no-feature-menubar -no-feature-mimetype -no-feature-mimetype-database -no-feature-movie -no-feature-optimize_debug -feature-optimize_size -no-feature-pdf -no-feature-printdialog -no-feature-printer -no-feature-printpreviewdialog -no-feature-printpreviewwidget -no-feature-progressbar -no-feature-progressdialog -no-feature-proxymodel -no-feature-radiobutton -no-feature-raster-64bit -no-feature-release_tools -no-feature-resizehandler -no-feature-rubberband -no-feature-scrollarea -no-feature-scrollbar -no-feature-scroller -no-feature-separate_debug_info -no-feature-shared -no-feature-sizegrip -no-feature-slider -no-feature-sortfilterproxymodel -no-feature-spinbox -no-feature-splashscreen -no-feature-splitter -no-feature-stackedwidget -no-feature-standarditemmodel -no-feature-statemachine -feature-static -feature-static_runtime -no-feature-statusbar -no-feature-statustip -no-feature-stringlistmodel -no-feature-syntaxhighlighter -no-feature-systemtrayicon -no-feature-tabbar -no-feature-tabletevent -no-feature-tableview -no-feature-tablewidget -no-feature-tabwidget -no-feature-textbrowser -no-feature-textedit -no-feature-texthtmlparser -no-feature-textmarkdownreader -no-feature-textmarkdownwriter -no-feature-textodfwriter -no-feature-timezone -no-feature-toolbar -no-feature-toolbox -no-feature-toolbutton -no-feature-tooltip -no-feature-topleveldomain -no-feature-translation -no-feature-transposeproxymodel -no-feature-treeview -no-feature-treewidget -no-feature-undocommand -no-feature-undogroup -no-feature-undostack -no-feature-undoview -no-feature-validator -no-feature-whatsthis -no-feature-wheelevent -no-feature-widgettextcontrol -no-feature-wizard -confirm-license -nomake examples -nomake tests -nomake tools -opensource -platform win32-g++ -prefix "C:\Qt\Static.15.2"

此列表随我要使用此 Qt 构建的项目一起提供。

使用 https://github.com/McNopper/EGL

中的 EGL

以下是我如何从 MSYS2 构建和安装它以便它与 Qt 一起工作:

# change the install path below as needed
INSTALLPREFIX=/D/Prog/build

# fix missing egl.pc
cat > egl.pc << EOF
prefix=$INSTALLPREFIX
libdir=${prefix}/lib
includedir=${prefix}/include

Name: egl
Description: EGL implementation supporting OpenGL
Version: $VERSION
Libs: -L${libdir} -legl
Cflags: -I${includedir}
EOF
# fix EGL/CMakeLists.txt
patch -ulbf EGL/CMakeLists.txt << EOF
@@ -25,2 +25,5 @@
     ${EGL_SOURCES})
+add_library(egl_shared SHARED
+    ${EGL_SOURCES})
+set_target_properties(egl_shared PROPERTIES OUTPUT_NAME egl)

@@ -28,2 +31,4 @@
     ${CMAKE_CURRENT_LIST_DIR}/include)
+target_include_directories(egl_shared PUBLIC
+    ${CMAKE_CURRENT_LIST_DIR}/include)
 add_definitions(-DEGLAPI=)
EOF
mkdir -p build &&
 cmake.exe -Wno-dev -G"MSYS Makefiles" -DCMAKE_INSTALL_PREFIX:PATH=$INSTALLPREFIX -DCMAKE_BUILD_TYPE:STRING=Release -SEGL -Bbuild &&
 echo "-Wl,--as-needed -lopengl32 -lglew32" >> build/CMakeFiles/egl_shared.dir/linklibs.rsp &&
 make -Cbuild &&
 strip build/*.dll &&
 mkdir -p $INSTALLPREFIX/include $INSTALLPREFIX/lib/pkgconfig $INSTALLPREFIX/bin &&
 cp -rf EGL/include/* $INSTALLPREFIX/include/ &&
 cp -f build/lib*.a $INSTALLPREFIX/lib/ &&
 cp -f build/*.dll $INSTALLPREFIX/bin/ &&
 cp -f egl.pc $INSTALLPREFIX/lib/pkgconfig/ &&
 echo SUCCESS

以上内容依赖于 glew,它可以从 http://sourceforge.net/projects/glew/files/glew/ 的源代码构建,如下所示:

# change the install path below as needed
INSTALLPREFIX=/D/Prog/build

mkdir -p build_win &&
 cmake.exe -Wno-dev -GNinja -DCMAKE_INSTALL_PREFIX:PATH=$INSTALLPREFIX -DCMAKE_BUILD_TYPE:STRING=Release -DBUILD_UTILS:BOOL=ON -Sbuild/cmake -Bbuild_win &&
 ninja -Cbuild_win &&
 # manually build libglew32mx
 gcc -DGLEW_MX -O2 -Wall -W -Iinclude -DGLEW_BUILD -o src/glew.mx.o -c src/glew.c &&
 gcc -fno-builtin -fno-stack-protector -shared -s -Wl,-soname,libglew32mx.dll -Wl,--out-implib,lib/libglew32mx.dll.a -o lib/glew32mx.dll src/glew.mx.o -Wl,--as-needed -lglu32 -lopengl32 -lgdi32 -luser32 -lkernel32 -nostdlib &&
 ar cr lib/libglew32mx.a src/glew.mx.o &&
 ninja -Cbuild_win install/strip &&
 # manually install libglew32mx
 cp -f lib/libglew32mx*.a $INSTALLPREFIX/lib/ &&
 cp -f lib/glew32mx.dll $INSTALLPREFIX/bin/ &&
 sed -e "s/-lglew32/-lglew32mx/; s/^Cflags: /&-DGLEW_MX /" $INSTALLPREFIX/lib/pkgconfig/glew.pc > $INSTALLPREFIX/lib/pkgconfig/glewmx.pc &&
 # manually install where needed
 cp -f include/GL/eglew.h $INSTALLPREFIX/include/GL/ &&
 mkdir -p $INSTALLPREFIX/cmake &&
 cp -f build/cmake/*.cmake $INSTALLPREFIX/cmake/ &&
 cp -f build_win/CMakeFiles/Export/lib/cmake/glew/*.cmake $INSTALLPREFIX/cmake/ &&
 sed -i -z -e "s/\(get_filename_component(_IMPORT_PREFIX \"${_IMPORT_PREFIX}\" PATH)\n\)\{3\}//" $INSTALLPREFIX/cmake/glew-targets.cmake &&
 echo SUCCESS

我使用 -no-opengl 标志解决了这个问题。

这是我的完整 configure 列表:

./configure -release -opensource -confirm-license -prefix ".\MinGW" -platform win32-g++ -nomake examples -nomake tests -no-opengl