【发布时间】:2016-07-12 16:41:07
【问题描述】:
我在制作简单的 OpenGL 程序时遇到了麻烦。 我做了一些研究,发现可以制作我需要的 OpenGL 程序
- SFML - 用于创建窗口
- GLEW - 用于扩展处理
我使用 SFML 已经有一段时间了,效果很好。按照官方 SFML 页面,并添加一个额外的链接器选项:-l opengl32 我设法编译了显示的典型 OpenGL-with-SFML 代码Here.
所以我继续制作 OpenGL 应用程序,但我无法编译网上的任何教程,因为即使在设置 GLEW 之后也存在未定义的引用。现在我有this piece of code 来自here 的最不受欢迎的答案。我已按照该帖子中的说明进行操作,但仍然出现错误:
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c||对 `wglGetProcAddress@4' 的未定义引用
我正在使用
- Windows 10
- 代码块 16.1
- 默认 MinGW 包含代码块
- (SFML,GLEW)
**编辑:**
我的完整构建日志:
-------------- Build: Debug in opengl_minus1 (compiler: GNU GCC Compiler)---------------
mingw32-g++.exe -LC:\prog\SFML\2.3.2\lib -LC:\prog\GLEW\1.13\lib -o bin\Debug\opengl_minus1.exe obj\Debug\main.o -l opengl32 C:\prog\SFML\2.3.2\lib\libsfml-graphics.a C:\prog\SFML\2.3.2\lib\libsfml-window.a C:\prog\SFML\2.3.2\lib\libsfml-system.a C:\prog\GLEW\1.13\lib\libglew32.a
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x29c): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x2b8): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x2d4): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x2e8): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x2fc): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x310): more undefined references to `wglGetProcAddress@4' follow
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x1786c): undefined reference to `glGetString@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x178bf): undefined reference to `wglGetCurrentDC@0'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x1792f): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x17943): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x1795e): undefined reference to `wglGetCurrentDC@0'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x179da): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x17b60): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x17b7c): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x17b9a): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x17f7c): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x17f98): more undefined references to `wglGetProcAddress@4' follow
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x19def): undefined reference to `glGetString@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x19f40): undefined reference to `glGetString@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x19f85): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x19fa1): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x19fbd): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x19fd6): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x1a08f): undefined reference to `wglGetProcAddress@4'
C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj):glew.c:(.text+0x1a0ab): more undefined references to `wglGetProcAddress@4' follow
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: C:\prog\GLEW\1.13\lib\libglew32.a(glew.obj): bad reloc address 0x13a98 in section `.rdata'
C:/Program Files (x86)/CodeBlocks/MinGW/bin/../lib/gcc/mingw32/4.9.2/../../../../mingw32/bin/ld.exe: final link failed: Invalid operation
collect2.exe: error: ld returned 1 exit status
Process terminated with status 1 (0 minute(s), 0 second(s))
26 error(s), 0 warning(s) (0 minute(s), 0 second(s))
【问题讨论】:
-
你链接到
opengl32吗? -
有人建议我 -l opengl32 我相信它可以胜任。
-
要获得有关失败链接的帮助,您至少需要发布失败的链接命令和随之而来的错误,逐字逐句地从构建输出中发布。在您的问题正文中添加此信息。
标签: c++ opengl codeblocks sfml glew