今天在vs2008环境下配置好opengl后,测试一个小程序,发现有以下编译错误。
Error 1 error LNK2001: unresolved external symbol __imp____glutInitWithExit@12 opengltest.obj opengltest
Error 3 fatal error LNK1120: 2 unresolved externals
后来去h文件找到这样一条信息:
Note that the __glut*WithExit routines should NEVER be called directly.
To avoid the atexit workaround, #define GLUT_DISABLE_ATEXIT_HACK
因此在#include glut.h之前加入:
#define GLUT_DISABLE_ATEXIT_HACK
编译通过,运行ok。
后来又在网上验证了大家使用了同一解决方法。
如:
http://blog.csdn.net/xiajun07061225/article/details/6969877
http://942224632.blogbus.com/logs/150805541.html
http://wenku.baidu.com/view/285655c59ec3d5bbfd0a7452.html