
初学OpenGL,建立程序框架后,编译,结果报错说不能编译GL\GL.H,没有与文件拓展相关的编译工具。怎么解决
报错:connotcompilethefile'C:\ProgramFiles\MicrosoftVisualStudio\VC98\Include\GL\GL.H';n...
报错:connot compile the file'C:\Program Files\Microsoft Visual Studio\VC98\Include\GL\GL.H';no compile tool is associated with the file extention.
新建了个源文件:
#include<GL/gl.h>
int main()
{
}
编译,结果出错,如下:(我之前编译的出现了同样的错,可我修改不来)
Compiling...
a2.cpp
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
a2.exe - 3 error(s), 0 warning(s) 展开
新建了个源文件:
#include<GL/gl.h>
int main()
{
}
编译,结果出错,如下:(我之前编译的出现了同样的错,可我修改不来)
Compiling...
a2.cpp
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2144: syntax error : missing ';' before type 'void'
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : error C2501: 'WINGDIAPI' : missing storage-class or type specifiers
c:\program files\microsoft visual studio\vc98\include\gl\gl.h(1152) : fatal error C1004: unexpected end of file found
Error executing cl.exe.
a2.exe - 3 error(s), 0 warning(s) 展开
2个回答
展开全部
这个问题是说Visual Studio把这个gl.h文件当作一个编译单元来处理,
而一般情况下只会把.c、.cpp文件当作编译单元,
.h文件只会被include。
应该是工程的配置有问题,但是我也不确定怎么解决。。。
1.在工程里,你右键看看gl.h属性,记得好像有一个编译tool的选项,换几个别的试试。
2.在vs的设定里,好像有c/c++源文件后缀名的设定,你也可以改着试试。
===============
你试试先include <window.h>
这本书《OpenGL编程指南》里写着,推荐你看看这书。。。
对于所有的OpenGL应用程序,都需要在每个文件中包含OpenGL头文件。几乎所有的OpenGL应用程序都使用GLU(前面提到的OpenGL工具函数库)。要使用这个函数库,必须包含glu.h头文件。因此,几乎所有的OpenGL源代码文件都是以下面这两行开始的:
1. #include <GL/gl.h>
2. #include <GL/glu.h>
注意:Microsoft Windows要求在gl.h或glu.h之前包含windows.h头文件,因为MicrosoftWindows版本的gl.h和glu.h文件内部使用的一些宏是在windows.h中定义的。
而一般情况下只会把.c、.cpp文件当作编译单元,
.h文件只会被include。
应该是工程的配置有问题,但是我也不确定怎么解决。。。
1.在工程里,你右键看看gl.h属性,记得好像有一个编译tool的选项,换几个别的试试。
2.在vs的设定里,好像有c/c++源文件后缀名的设定,你也可以改着试试。
===============
你试试先include <window.h>
这本书《OpenGL编程指南》里写着,推荐你看看这书。。。
对于所有的OpenGL应用程序,都需要在每个文件中包含OpenGL头文件。几乎所有的OpenGL应用程序都使用GLU(前面提到的OpenGL工具函数库)。要使用这个函数库,必须包含glu.h头文件。因此,几乎所有的OpenGL源代码文件都是以下面这两行开始的:
1. #include <GL/gl.h>
2. #include <GL/glu.h>
注意:Microsoft Windows要求在gl.h或glu.h之前包含windows.h头文件,因为MicrosoftWindows版本的gl.h和glu.h文件内部使用的一些宏是在windows.h中定义的。
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询