我想为Dev-c ++安装glut库,我执行以下操作:
glut.h, glutf90.h
从include\GL
复制到MinGW64\include\GL
和MinGW64\x86_64-w64-mingw32\include\GL
(我不知道正确的文件夹在哪里,所以我添加到其他地方...)libglut32.a
从lib\
复制到MinGW64\lib
(来自youtube here的参考)-lglut32 -lglu32 -lopengl32 -lwinmm -lgdi32
// Lab01_Perimitives.cpp
/* -- INCLUDE FILES ------------------------------------------------------ */
#include <gl/gl.h>
#include <gl/glu.h>
#include <gl/glut.h>
/* ----------------------------------------------------------------------- */
void myInit( void ) {
glClearColor( 0.0, 0.0, 0.0, 0.0 );
glColor3f( 1.0, 0.0, 1.0 );
glPointSize( 3.0 );
glMatrixMode( GL_PROJECTION );
glLoadIdentity( );
glOrtho(0.0, 1.0, 0.0, 1.0, -1.0, 1.0);
}
/* ----------------------------------------------------------------------- */
/* ----------------------------------------------------------------------- */
void myDisplay( void ) {
glClear( GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );
glBegin(GL_POLYGON);
glColor3f(1.0f,0.0f,0.0f);
glVertex3f(0.25, 0.25, 0.0);
glColor3f(0.0f,1.0f,0.0f);
glVertex3f(0.75, 0.25, 0.0);
glColor3f(0.5f,0.5f,1.0f);
glVertex3f(0.75, 0.75, 0.0);
glColor3f(0.0f,0.0f,1.0f);
glVertex3f(0.25, 0.75, 0.0);
glEnd();
glutSwapBuffers();
}
/* ----------------------------------------------------------------------- */
int main( int argc, char *argv[] ) {
// Initialize GLUT.
glutInit( &argc, argv );
// Set the mode to draw in.
glutInitDisplayMode( GLUT_DOUBLE | GLUT_RGB );
// Set the window size in screen pixels.
glutInitWindowSize( 640, 480 );
// Set the window position in screen pixels.
glutInitWindowPosition( 100, 150 );
// Create the window.
glutCreateWindow( "Lab01" );
// Set the callback funcion to call when we need to draw something.
myInit( );
glutDisplayFunc( myDisplay );
// Initialize some things.
// Now that we have set everything up, loop responding to events.
glutMainLoop( );
}
/* ----------------------------------------------------------------------- */
但是当我编译时,我得到了这些错误:
c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe skipping incompatible C:/Program Files (x86)/Dev-Cpp/MinGW64/lib/libglut32.a when searching for -lglut32
c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe skipping incompatible c:/program files (x86)/dev-cpp/mingw64/bin/../lib/gcc/x86_64-w64-mingw32/4.8.1/../../../../lib/libglut32.a when searching for -lglut32
...etc...
c:\program files (x86)\dev-cpp\mingw64\x86_64-w64-mingw32\bin\ld.exe cannot find -lglut32
E:\Mon hoc\Do hoa may tinh\Lab01\collect2.exe [Error] ld returned 1 exit status
E:\Mon hoc\Do hoa may tinh\Lab01\Makefile.win recipe for target 'Lab01.exe' failed
这里有什么问题,如何解决?
我的电脑运行Windows 8.1 64位