fatal error C1083: 无法打开包括文件:stdafx.h
stdafx是标准应用程序框架的扩展,即Standard Application Framework Extensions的简写,它是与预编译文件*.pch相关联的。一般MFC程序文件的第一句都为:#include "stdafx.h"。
我们要注意的一点就是:#include "stdafx.h"之前的所有代码都会被忽略,因此我们在编写VS程序时这段代码应该放在首句,否则其他的头文件将会被忽略执行以出现这样的错误
fatal error C1083: 无法打开包括文件: “stdafx.h”: No such file or directory
操作方法
- 01
新建一个控制台应用程序
- 02
将以下语句复制到主文件中 #include "stdafx.h" #include <iostream> #include<gl/glut.h> using namespace std; void renderScene(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glLoadIdentity(); glBegin(GL_TRIANGLES); glVertex3f(-0.5, -0.5, 0.0); glVertex3f(0.5, 0.0, 0.0); glVertex3f(0.0, 0.5, 0.0); glEnd(); glutSwapBuffers(); } int _tmain(int argc, _TCHAR* argv[]) { glutInit(&argc, (char**)argv); glutInitDisplayMode(GLUT_DEPTH | GLUT_DOUBLE | GLUT_RGBA); glutInitWindowPosition(100, 100); glutInitWindowSize(320, 320); glutCreateWindow("Hello OpenGL"); glutDisplayFunc(renderScene); glutMainLoop();//enters the GLUT event processing loop. system("pause"); return 0; }
- 03
编译运行即可通过