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..
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.
#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.
I want to begin programming with C++ OpenGl, and thus have downloaded freeglut to be included in my programn.
I have defined statically FREEGLUT_STATIC
Here is my source.cpp:
#include <GL\glew.h>
#include <GL\GLU.h>
#include <GL\freeglut.h>
#include "Source.h"
using namespace std;
int main()
{
return 0;
}
source.h
#define FREEGLUT_STATIC
But it does not work, the error is:
1>LINK : fatal error LNK1104: cannot open file 'freeglut.lib'
It's worth mentioning that I have added the libraries directories to the project, and even when I type Gl/ visual studio 2013 automatically suggest the libraries and headers which means it knows the directory,
I have found the problem. I should simlpy do the following:
Right click on my project in Visual Studio, go to the properties, and then to VC++ Directories, click on "Library Directories" and then add a new path:
under the freeglut main directory in your hard drive, there is a folder called lib/x86/Debug, just add the full path and then apply that.
Your script should be executed properly.
The include works alright (otherwise you'd get an error at compile time, not at link time). The library file itself (freeglut.lib) seems to be missing. This SO question addreses your problem.
EDIT: Updated my answer because obviously just the binary for the lib is missing. Same link already given in a comment by swaldi.
I am working in visual studio and i have got two projects in a solution.
I want to refer to header file of second project in my main-project.
I added second-prj as a reference to my main-prj,. But when i write like
#include "Second_Project_File.h"
in my main-prj it gives compile errors :
fatal error C1083: Cannot open include file: 'Second_Project_File.h': No such file or directory.
Then i looked at the folders and gave relative path like
#include "..\Second_Project_Folder\Second_Project_File.h"
it compiled but gave error :
main-prj.exe not found or not built by the last incremental link; performing full link
Embedding manifest...
What should i do?
i donot want to work with this kind of including header files
#include "..\somefolder\header.file.h"
How to do this in visual studio.
Thanks.
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.