gpt4 book ai didi

c++ - GLFW MinGW 链接错误

转载 作者:可可西里 更新时间:2023-11-01 15:39:26 25 4
gpt4 key购买 nike

我已经尝试用 C++ 测试 GLFW 很长一段时间了,但一直遇到链接器问题。我是 C++ 的新手,虽然我有 Java 和 C# 的经验,但直接使用编译器对我来说还是很新的。这是我的设置信息。

集成开发环境:Qt Creator

操作系统:Windows 7 64 位

编译器:MinGW32 4.8.1

01:23:26: Starting: "C:\MinGW\bin\mingw32-make.exe" 
C:/MinGW/bin/mingw32-make -f Makefile.Debug
mingw32-make[1]: Entering directory 'A:/workspace_cpp/Test-Debug'
g++ -Wl,-subsystem,console -mthreads -o debug\Test.exe debug/main.o -lglfw3 -lopengl32
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libglfw3.a(win32_monitor.c.obj):win32_monitor.::(.text+0x2c7): undefined reference to `CreateDCW@16'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x358): undefined reference to `GetDeviceCaps@8'
Makefile.Debug:77: recipe for target 'debug\Test.exe' failed
mingw32-make[1]: Leaving directory 'A:/workspace_cpp/Test-Debug'
Makefile:34: recipe for target 'debug' failed
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libglfw3.a(win32_monitor.c.obj):win32_monitor.c:(.text+0x370): undefined reference to `GetDeviceCaps@8'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libglfw3.a(win32_monitor.c.obj):win32_monitor .c:(.text+0x39e): undefined reference to `DeleteDC@4'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../libglfw3.a(win32_monitor.c.obj): bad reloc address 0x20 in section `.eh_frame'
c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status

我正在测试的代码是 GLFW Documentation Page 上的代码,我正在使用自己构建的 GLFW,and have already tried this和其他几个潜在的解决方案。我曾尝试使用预构建的 GLFW mingw 库,但我无法让它们工作。

最佳答案

enhzflep 发布的解决方案是在编译时包含到 gdi32 库,制作所有必要的链接器 -lglfw3 -lgdi32 -lopengl32,作为缺少的方法,CreateDCW , GetDeviceCapsDeleteDC 都在 MinGW lib 文件夹 C:\MinGW\lib\libgdi32.a 在这种情况下。

关于c++ - GLFW MinGW 链接错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22008845/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com