#include <stdafx.h>
i checked error C1083: Cannot open include file: 'stdafx.h': No such file or directory in VS 2005
but it still didn't help. im using precompiled headers. Usually i start out with a template ive saved for myself. that has all the headers i like, and in the past the include has worked. Also i would attach code, but its not allowing me to access it on any proj at all. even a simple hello world.
Try #include "stdafx.h".
This will change the way the compiler looks for the header - namely, it will check the local directory.
Here is the SO question for further reference.
Related
I try to compile a cpp file with this header:
#include <stdlib.h>
#include <gtk/gtk.h>
I work with MSYS2, so both the compiler and the gtk library are installed through it. The cpp compiler path is:
D:\msys\usr\bin\cpp.exe
and here is the VS code include path additions, which I supplied to the IntelliSense Configurations page under "include path":
D:\msys\mingw64\include\gtk-2.0\**
D:\msys\mingw64\include\**
D:\msys\mingw64\lib\**
D:\msys\usr\include\**
and I have gtk etc. in the include folder. I actually installed three different versions of gtk, 2-4.
Before I added them to the include path, I got an error like "cannot open source file", and after adding them I get the
fatal error: gtk/gtk.h: No such file or directory
error. gtk/gtk.h is located just inside gtk-2.0. What am I doing wrong?
Thanks a lot.
I've been handed the source code for a very large c++ project and asked to make a small change to support some new hardware. I'm not very familiar with c++, as I mostly use C# these days.
When I built the project I'm getting 20+
Error 2 error C1083: Cannot open include file: 'StdAfx.h': No such file or directory D:.. thefile.cpp
From my understanding the "StdAfx.h" is to do with precompiled headers, and is automatically generated?
I followed the answer on this question:
1 Ensure you have the file "stdafx.h" in your project. If you don't
(e.g. you removed it) just create a new temporary project and copy the
default one from there;
but in doing so noticed that the created stdafx.h file doesn't have the capitalisation of the referenced "StdAfx.h"
I managed to get rid of a single error by copying in the generated file from a new project and changing:
#include "StdAfx.h"
to:
#include "stdafx.h"
I can't help but think this project was using StdAfx.h (there are about 150 references to it) for a reason, and that I shouldn't be adding a bunch of stdafx.h and stdafx.cpp files scattered around the place.
Is there some way of referencing a global stdafx.h file that was being used that could be causing this error?
In Windows, file names are not case-sensitive.
You can't expect that someone else stdafx.h file will be useful in your project. You need to find the original one.
Typically, one project uses one header file for precompiled header, shared by every source file that includes it.
I'm attempting to compile a C++ solution in VS 2010, but for some reason it can't locate the standard libraries.
I'm including as so:
#include <cstddef>
VS is returning an error as so:
main.cpp(10): fatal error C1083: Cannot open include file: 'cstddef': No such file or directory
However, I check my installation directory, and it's right where it's supposed to be (VC\include), and this directory is a part of my include directory list in the project settings ($(VCInstallDir)include).
Any ideas why this is happening, and how I can fix it?
Give a try using #include <stddef.h> instead.
However, MSVC 10 should have <cstddef>: msdn
However, as #captain-obvlious pointed out this may require additional changes in your code..
I'm working with an API which has #defineed all their include files. I'm developing in Visual C++ 2010 Express, and it's been working fine up till now.
I was adding a new cpp-file to the project, and accidentally added a "Windows Form" instead. VC warned me that my project was not using CLR at the moment, did I really want to? I clicked no, and added the file as intended. After that, however, my project no longer compiles.
The code looks basically like this:
api_header.h:
#define DEFINED_HEADER_NAME "path/to/header/file.h"
stdhpf.h:
#include DEFINED_HEADER_NAME
As I said, worked fine for a long time. Now I get this:
error C2006: '#include' : expected a filename, found 'identifier'
fatal error C1083: Cannot open include file: '': No such file or directory
What is causing this? I found some post that said it was because of having turned on precompiled headers, but I checked Project properties > Configuration properties > C/C++ / Precompiled headers, and it's off (I mention the setting path since I'm new to VS, there might be more than one way to do it...).
Any ideas?
The problem almost certainly lies in the order in which the two statements are pre-processed, rather than having anything to do with inadvertently adding a Windows Form object.
This knowledge base article suggests:
The problem is in using a defined constant to specify an include file in the #include directive. The directive is being processed before the macro is completely expanded, resulting in the error.
The second error seems to confirm this, as it indicates the pre-processor is searching for an include file with an empty name:
fatal error C1083: Cannot open include file: '': No such file or directory
The order of your include files has changed. Perhaps Visual Studio inserted a #include "stdhpf.h" somewhere ahead of your #include "api_header.h".
Disable precompiled headers. It should helps.
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.
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".
"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.