【问题标题】:Building Qt 5.15.2 using MinGW-64: Build Error (missing EGL/egl.h)使用 MinGW-64 构建 Qt 5.15.2:构建错误(缺少 EGL/egl.h)
【发布时间】:2021-06-29 11:50:35
【问题描述】:

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

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

qwindowseglcontext.h: 45: 10: 致命错误:EGL / egl.h: 没有这样的文件或目录

我知道它缺少标题,但我找不到有关如何更正此问题的可行解释。经过一番研究,我遇到了https://cn.khronos.org/egl/,但下载链接已失效,我还看到有人说可以使用 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-command-linkbutton -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 -一世conv -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 -不-特征滚动区域-无特征滚动条-无特征滚动条-无特征分离调试信息-无特征共享-无特征大小握把-无特征滑块-无特征排序过滤代理模型-无特征- 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 -无特征文本浏览器 -无特征文本编辑 -无特征文本html解析器 -无特征文本markdownreader -无特征文本markdownwriter -无特征文本odfwriter -无特征时区 -无特征工具栏 -无 -功能工具箱-无功能工具按钮-无功能工具提示-无功能顶级域-无功能翻译-无功能转置代理模型-无功能树视图-无功能树wid获取 -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 示例 -nomake 测试 -nomake 工具 -opensource -platform win32-g++ -prefix "C:\Qt\Static\5.15.2"

此列表随附于我要使用此 Qt 构建的项目。

【问题讨论】:

    标签: c++ qt opengl-es mingw


    【解决方案1】:

    使用来自 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\}/\1/" $INSTALLPREFIX/cmake/glew-targets.cmake &&
     echo SUCCESS
    

    【讨论】:

    • 首先感谢您的帮助。我看到编译需要包含glew32,但我个人需要在没有任何dll的情况下静态编译Qt。有没有办法跳过 glew dll ? (不破坏 EGL?)
    • 为什么不用glew32?您可以只链接静态 glew32...我编辑了我的答案,其中包含构建 glew 的说明。
    • 感谢您的解释。我尝试了很多时间来使用您提供的命令来构建,即使在 MSYS2 上修复了 ninja 或 cmake 等依赖关系问题之后,我也无法继续编译它。第一个错误是,找不到 C & CCX 编译器,我给了它 gcc 路径,之后仍然没有。 MSYS2 对我来说似乎很神秘
    • MSYS2 允许您像在 Linux/Unix 上一样做很多事情,因为它提供了一个 bash shell。我看到您尝试从批处理文件中使用 MinGW 构建 Qt。我从来没有让它正常工作。如果您仍然无法找到编译器,请尝试从 winlibs.com 下载独立编译器包,将其解压缩并将其添加到 PATH 变量的前面。在 MSYS 中,这可以通过 export PATH=/d/Prog/winlibs64/mingw64/bin:$PATH 之类的方式完成
    • 我今天将尝试使用 MSVC 编译器编译所有内容。它通常不太合规,但结果也不太棘手。另外,您知道您提供的 EGL 是否需要 glew 1.12.0 或支持 2.1.0 ? (我真的不知道如何用 MinGW 编译所有东西,glew 似乎可以用 MSVC 构建)
    【解决方案2】:

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

    这是我的完整 configure 列表:

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

    【讨论】:

    • 那不解决问题,这只是一个“绕过”。通过添加 -no-opengl 标志,静态构建的 QT 会遗漏很多需要的功能。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-23
    • 1970-01-01
    • 1970-01-01
    • 2020-08-25
    • 2017-08-19
    • 2011-05-22
    • 2023-04-03
    相关资源
    最近更新 更多