开发者

why compiling GLUT project in NetBeans with MinGW doesnt work

开发者 https://www.devze.com 2022-12-30 08:19 出处:网络
I have this situation, I use Netbeans 6.8 with recommended MinGW+msys configuration, and compiling works. Now I have a project which is using glut, so I linked the libraries opengl32, glut32, glu32, g

I have this situation, I use Netbeans 6.8 with recommended MinGW+msys configuration, and compiling works. Now I have a project which is using glut, so I linked the libraries opengl32, glut32, glu32, gdi32, winmm, mingw32 in "project properties->build->linker->libraries", i manually selected all .lib files and the compilation works!

But, then I added some other h and cpp files to the project (texture loaders etc.), which use glut and they #include it and the IDE seems fine with it, but when I try to compile the code, errors comes up when compiling those files:

.../Terrain.cpp:132: undefined reference to `_imp__glVertex3fv'
.../Terrain.cpp:135: undefined reference to `_imp__glTexCoord2d'
.../Terrain.cpp:139: undefined reference to `_imp__glNormal3fv'
.../Terrain.cpp:140: undefined reference to `_imp__glVertex3fv'

And tons more. In my understanding this means that lib files are not linked, but they ARE linked in the project and the main file can use all these without problem.

I tried everything but I'm probably missing something. Also the project (creating new project from the files in vs2010) can be compiled using vs2010 compiler.

Please help, does anyone have expirience in linking libraries with MinGW in Net开发者_Python百科Beans?


The "answer" is not to include windows.h before this, that, or the other. You just need to ensure that the __stdcall convention is used in glut32.dll.

Follow the procedure for building the GLUT library for Win32 with MinGW at the following location:

http://www.mingw.org/wiki/HOWTO_Compile_the_OpenGL_Utility_Toolkit_GLUT_for_Win32_with_MinGW


Every single file using glut.h needs to have included windows.h before including gl.h or glut.h..

Took quite some of my time, hope it helps someone (I was searching for solution here too).

Note: I found the answer here link text, in section 2.070, there is error, such as ...undefined reference to ..., described, but the windows.h solution is described in other type of error (

c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : 
error C2054: expected '(' to follow 'WINGDIAPI'
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : 
error C2085: 'APIENTRY' : not in formal parameter list

)

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号