Windows OpenGL&x2B;GLEW&x2B;MinGW应用程序链接问题

Windows OpenGL&x2B;GLEW&x2B;MinGW应用程序链接问题,windows,opengl,mingw,eclipse-cdt,glew,Windows,Opengl,Mingw,Eclipse Cdt,Glew,在构建项目时,我得到了一些未定义的引用。以下是生成日志: **** Build of configuration Debug for project test **** **** Internal Builder is used for build **** g++ -O0 -g3 -Wall -c -fmessage-length=0 -o src\main.o ..\src\main.cpp g++ -O0 -g3 -Wall -c -fmessage-leng

在构建项目时,我得到了一些未定义的引用。以下是生成日志:

**** Build of configuration Debug for project test ****

**** Internal Builder is used for build               ****
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o src\main.o ..\src\main.cpp
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o src\test.o ..\src\test.cpp
g++ -O0 -g3 -Wall -c -fmessage-length=0 -o src\window.o ..\src\window.cpp
..\src\window.cpp: In member function 'void Window::StartRenderContext()':
..\src\window.cpp:150:24: warning: NULL used in arithmetic
..\src\window.cpp:161:28: warning: NULL used in arithmetic
..\src\window.cpp:174:24: warning: NULL used in arithmetic
g++ -mwindows -l glew32 -l glew32s -l glu32 -l opengl32 -o test.exe src\window.o src\test.o src\main.o
src\window.o: In function `ZN6Window18StartRenderContextEv':
C:\eclipse\workspace\test\Debug/../src/window.cpp:101: undefined reference to `wglCreateContext@4'
C:\eclipse\workspace\test\Debug/../src/window.cpp:102: undefined reference to `wglMakeCurrent@8'
C:\eclipse\workspace\test\Debug/../src/window.cpp:115: undefined reference to `glewInit'
C:\eclipse\workspace\test\Debug/../src/window.cpp:125: undefined reference to `wglMakeCurrent@8'
C:\eclipse\workspace\test\Debug/../src/window.cpp:126: undefined reference to `wglDeleteContext@4'
C:\eclipse\workspace\test\Debug/../src/window.cpp:148: undefined reference to `__wglewChoosePixelFormatARB'
C:\eclipse\workspace\test\Debug/../src/window.cpp:159: undefined reference to `__wglewChoosePixelFormatARB'
C:\eclipse\workspace\test\Debug/../src/window.cpp:185: undefined reference to `__wglewCreateContextAttribsARB'
C:\eclipse\workspace\test\Debug/../src/window.cpp:194: undefined reference to `__wglewCreateContextAttribsARB'
C:\eclipse\workspace\test\Debug/../src/window.cpp:204: undefined reference to `__wglewCreateContextAttribsARB'
C:\eclipse\workspace\test\Debug/../src/window.cpp:214: undefined reference to `__wglewCreateContextAttribsARB'
C:\eclipse\workspace\test\Debug/../src/window.cpp:227: undefined reference to `wglMakeCurrent@8'
collect2: ld returned 1 exit status
Build error occurred, build is stopped
Time consumed: 8128  ms. 
这是我的链接命令:

g++ -mwindows -l glew32 -l glew32s -l glu32 -l opengl32 -o test.exe src\window.o src\test.o src\main.o
这是正确的吗?我使用的是glew的64位二进制文件(我认为32位没有任何意义)。它们是否仅用于visual studio

以下是我的代码中包含的内容:

#include "Windows.h"
#include "GL/glew.h"
#include "GL/wglew.h"
#include "GL/gl.h"
#include "GL/glu.h"
#include "test.h"
我正在使用Eclipse Indigo CDT、MinGW、Win32、OpenGL和glew。

我解决了“glew未定义引用”问题

我的开发环境是Windows7(x64)上带有MinGW的EclipseCDT

解决方案包括以下3个步骤:

  • 添加源代码:
    \define GLEW\u STATIC
  • 添加链接器标志:
    -lglew32s-lopengl32-lfreeglut
  • 添加编译标志:
    gcc-DGLEW_STATIC

  • 如果需要,您必须添加
    -lglu32-glut32
    等。

    为什么要包括
    wglew.h
    ?为什么在包含
    glew.h
    之后还要包含
    gl.h
    ?我正在使用wglew用wgl初始化glew,我相信这是实现这一点所需的专用库。关于gl和glu,我把它们包括进来,希望它能解决函数调用。它没有,所以我可以试着移除它们。我也会删除wglew,看看这是否真的能解决这些问题,我不确定。好的,我已经把包含的范围缩小到只包含
    glew.h
    wglew.h
    ,我现在也只包含
    glew32s.lib
    ,已经定义了
    GLEW_STATIC
    ,但我仍然得到了完全相同的未定义引用!如果有人在Eclipse Indigo CDT环境中使用MinGW尝试一个glew应用程序,他们可以发布他们的结果吗?xDI解决了它!我刚刚决定他们在sourceforge中建立的预编译二进制文件只用于visual studio,所以我下载了源代码并为MinGW构建了它,现在它可以工作了!!啊,我们在安装第三方库时学到的东西。。。我会在8小时后发布答案。所以@AutoBotAM。。。答案是什么?除息的