Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

error C1083: Cannot open include file: 'stdafx.h': No such file or directory in VS 2005

Tags:

c++

windows

I am new to visual studio.I have created a simple console application and then selected an empty project of c++. I have pasted the code form
http://www.cprogramming.com/tutorial/opengl_first_windows_app.html

it is giving the following error error C1083: Cannot open include file: 'stdafx.h': No such file or directory.

Can any body help me how ti solve that issue.

Also i have pasted the code from
http://www.cprogramming.com/tutorial/opengl_windows_programming.html

and it gives me error in MessageBox function.

like image 313
Abdul Samad Avatar asked Apr 04 '11 23:04

Abdul Samad


2 Answers

Fall in the pit of success by using an appropriate project template. Which is Win32 + Win32 Project, don't tick the "Empty project" option on the property page. You'll get pre-generated code for a Win32 application, take a look at it since you might want to keep parts of it. Or just delete it all past the #include for stdafx.h and replace it with the code you want to try. The stdafx.h file is already pre-cooked for you.

The second snippet probably fails to compile because the code sample is not using Unicode strings. Put an L in front of the string literal, like L"\tHello world".

like image 131
Hans Passant Avatar answered Nov 19 '22 05:11

Hans Passant


"stdafx.h" is the default name for the precompiled header in Visual Studio.

If you are not using precompiled headers you can omit that include directive.

See this article on Wikipedia for an explanation of precompiled headers.

like image 38
xDD Avatar answered Nov 19 '22 06:11

xDD