I just installed the OpenGL library (actually most of source done in my computer already) and I try to compile the first program.
For x86 was run perfectly, however, for x64 that I config and redirect glut32.lib from
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib
to
C:\Program Files (x86)\Microsoft SDKs\Windows\v7.0A\Lib\x64
error has occur as below, I don’t know to solve this problem. The error seem like I haven’t link the library correctly?
error LNK2019: unresolved external symbol __imp_glutSwapBuffers referenced in function "void __cdecl drawcube(void)" (?drawcube@@YAXXZ)
error LNK2019: unresolved external symbol __imp_glutMainLoop referenced in function main
error LNK2019: unresolved external symbol __imp_glutIdleFunc referenced in function main
error LNK2019: unresolved external symbol __imp_glutDisplayFunc referenced in function main
My testing code is like this
<!-- language: cpp -->
void drawcube(void)
{
glClear(GL_COLOR_BUFFER_BIT);
glColor3f(1.0, 1.0, 1.0);
glMatrixMode(GL_MODELVIEW);
glRotatef(angle, 0.0, 1.0, 0.0);
glBegin(GL_LINE_LOOP);
glVertex3iv(a);
glVertex3iv(b);
glVertex3iv(c);
glVertex3iv(d);
glEnd();
glFlush();
glutSwapBuffers();
}
<!-- language: cpp -->
int main(int argc, char **argv)
{
glutInit(&argc, argv);
glutInitWindowSize(800, 600);
glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
glutCreateWindow("Test OpenGL");
glutDisplayFunc(drawcube);
glutIdleFunc(drawcube);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-30.0, 30.0, -30.0, 30.0, -30.0, 30.0);
glRotatef(30.0, 1.0, 0.0, 0.0);
glMatrixMode(GL_MODELVIEW);
glClearColor(0.0, 0.0, 0.0, 0.0);
glutMainLoop();
return(0);
}
Answer from @datenwolf was useful.
I just change to use freegult without error for complied in x64.
Huh? You mean you installed a OpenGL capbable driver (i.e. downloaded the driver from the GPU maker’s website, instead of using the crippled drivers shipping with Windows)? OpenGL usually doesn’t come in form of a library. It’s a specification for which implementations, usually in the form of drivers exist. Also you don’t need a special “OpenGL SDK” as all compilers ship with everything required to compile OpenGL programs. Whatever you installed, you probably don’t need it and it like does more harm than good.
Well, that’s not OpenGL, that’s GLUT. And GLUT is not part of OpenGL. It’s a 3rd party framework library, meant for the creation of small and simple OpenGL demonstrations. That one you actually must install on your system separately. I recommend using FreeGLUT (or not using GLUT at all). And unlike OpenGL where on both 32 bit and 64 bit architectures the DLL is called opengl32.dll, you need architecture specific versions of GLUT for this to compile properly. The old GLUT is unmaintained, hence there’s no 64 bit version of it. Thus my recommendation of FreeGLUT.