首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >GLFW MinGW链接错误

GLFW MinGW链接错误
EN

Stack Overflow用户
提问于 2014-02-25 16:46:16
回答 1查看 10.6K关注 0票数 15

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

IDE: Qt Creator

操作系统: Windows 7 64位

编译器: MinGW32 4.8.1

代码语言:javascript
复制
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库,但我无法让它们正常工作。

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2014-02-27 01:31:31

enhzflep发布的解决方案是在编译时包含到gdi32库中,使所有必要的链接器都是-lglfw3 -lgdi32 -lopengl32,因为缺少的方法、CreateDCWGetDeviceCapsDeleteDC都在MinGW库文件夹C:\MinGW\lib\libgdi32.a中的libgdi32.a中。

票数 26
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/22008845

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档