无法编译任何opengl / freeglut / glut源代码 [英] Cant compile any opengl/freeglut/glut source code
本文介绍了无法编译任何opengl / freeglut / glut源代码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个代码,我从opengl示例代码:
I have this code which i took from an opengl example code:
#include <GL/glut.h>
// Display callback ------------------------------------------------------------
void display()
{
// clear the draw buffer .
glClear(GL_COLOR_BUFFER_BIT); // Erase everything
// set the color to use in draw
glColor3f(0.5, 0.5, 0.0);
// create a polygon ( define the vertexs)
glBegin(GL_POLYGON); {
glVertex2f(-0.5, -0.5);
glVertex2f(-0.5, 0.5);
glVertex2f( 0.5, 0.5);
glVertex2f( 0.5, -0.5);
} glEnd();
// flush the drawing to screen .
glFlush();
}
// Keyboard callback function ( called on keyboard event handling )
void keyboard(unsigned char key, int x, int y)
{
if (key == 'q' || key == 'Q')
exit(EXIT_SUCCESS);
}
// Main execution function
int main(int argc, char *argv[])
{
glutInit(&argc, argv); // Initialize GLUT
glutCreateWindow("OpenGL example"); // Create a window
glutDisplayFunc(display); // Register display callback
glutKeyboardFunc(keyboard); // Register keyboard callback
glutMainLoop(); // Enter main event loop
return (EXIT_SUCCESS);
}
它应该能正常工作吗?
但是当我运行它:
it should work right? but when i run it:
Error 1 error LNK2019: unresolved external symbol __imp__glutMainLoop@0 referenced in function _main C:\Users\Naor\documents\visual studio 2012\Projects\test\test\Source.obj test
Error 2 error LNK2019: unresolved external symbol __imp__glutKeyboardFunc@4 referenced in function _main C:\Users\Naor\documents\visual studio 2012\Projects\test\test\Source.obj test
Error 3 error LNK2019: unresolved external symbol __imp__glutDisplayFunc@4 referenced in function _main C:\Users\Naor\documents\visual studio 2012\Projects\test\test\Source.obj test
Error 4 error LNK2019: unresolved external symbol __imp____glutInitWithExit@12 referenced in function _glutInit_ATEXIT_HACK@8 C:\Users\Naor\documents\visual studio 2012\Projects\test\test\Source.obj test
Error 5 error LNK2019: unresolved external symbol __imp____glutCreateWindowWithExit@8 referenced in function _glutCreateWindow_ATEXIT_HACK@4 C:\Users\Naor\documents\visual studio 2012\Projects\test\test\Source.obj test
Error 6 error LNK1120: 5 unresolved externals C:\Users\Naor\documents\visual studio 2012\Projects\test\Debug\test.exe 1 1 test
我安装opengl,freeglut正确(我的意思是,它运行和vc ++发现它没有问题),
但我不能运行任何源代码我发现..(同样的错误)
I installed opengl, freeglut correctly (i mean, it runs and vc++ find's it no problem), but i cant run any source code i find.. (same error's)
推荐答案
找到答案,任何人谁有这种问题检查这些:
Found the answer, to anyone who have this kind of issue check these:
- 您已正确链接了lib和include。 (建议使用32位,固定我的错误)。
- 完成后,您可能会收到无法打开或找到某个dll文件的错误。
- 检查dll是什么(在错误消息中),将其复制到您的exe所在的位置(对于调试模式到Debug文件夹,并释放到Release文件夹)。
希望修正错误:)
这篇关于无法编译任何opengl / freeglut / glut源代码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文