CodeBlocks配置openGL遇到的一些问题
1.1 配置openGL
给出我博客中的两个转载文章链接,描述的很详细了,欢迎请戳!
CodeBlocks配置GLUT
在CodeBlocks中使用openGL
1.2 一个补充
若是经过前面的配置仍然不行,也可以这么试试看。 在已存在的项目基础上右击 Project->Build Option ,在Linker Settings中add如下几个:
glut32
opengl32
glu32
winmm
gdi32
glaux
我当初就是一个程序配置好怎么都运行不起来,然后听了一个同学的建议,按照他的做法,add了上面几个,然后就ok了。偶也不知道他是从哪找到的这么一个方案。也不知道是否是凑巧,反正就先记下了吧。
1.3 遇到的两个很纠结的问题
苦逼地遇到两个问题,别的同学倒基本没遇到,偏偏我就都遇到了。。。编译就是通不过,纠结死了,后来按照下面的方法就搞定了。
No.1问题
某文件 undefined reference to '__某OpenGL函数名'
总之一大堆报红的错误。。。
这个问题在在CodeBlocks中使用openGL提到,可以参考它的做法,在包含OpenGL代码的include预编译指令前增加
#define _STDCALL_SUPPORTED
就成功了,就是把这个写在你的代码的最开头。
No.2问题
error:redeclaration of C++ built-in type 'wchar_t' [-fpermissive]
会跳出个代码文本,里面有这么几行
# ifndef _WCHAR_T_DEFINED
typedef unsigned short wchar_t;
# define _WCHAR_T_DEFINED
# endif
# endif
用google搜了下,可以参考这个人的回答问题原因
原文如下:
If wchart is already defined (to short for example), butthe WCHARTDEFINED macro(宏) is not, the line will then be treated as:
typedef unsigned short short;
Which is a redeclaration of the built-in type. (don't use the .h btw, it's not used anymore per standard) is adding defines such that the typedef is not executed, or undef'ing wchar_t if it is a macro such that the typedef is legal.
解决方法就是,在代码的开头(#include前面)加上:
#define _WCHAR_T_DEFINED
然后偶的问题就这么愉快地解决了