I am using Ubuntu 12.04.1 . The compiler I am using is gcc and my IDE is CodeBlocks . I am working with SDL under C/C++ . When I include "SDL/SDL.h" , the program gets compiled and the output is displayed . But including "SDL.h" gives an error :
fatal error: SDL.h: No such file or directory
|=== Build finished: 1 errors, 0 warnings ===|
Also there are 2 SDL.h files in /usr/include -
One is /usr/include/SDL/SDL.h
Other one is /usr/include/SDL.h
What is the difference between both the header files and why is only one path working ?
#include points to the folder "MinGW\include". Some people move their whole SDL folder there, so SDL.h is located in "SDL\SDL.h". Others just move their SDL.h to their include folder, meaning that they just need to use "SDL.h"
I'm not sure why you have 2 copies of SDL.h or what that is, but does this help? '"SDL.h" no such file or directory found' when compiling
If you made a copy you should delete it.
This:
#include "myheader.h"
looks for a file named myheader.h while this:
#include "MyFolder\myheader.h"
looks for a file named myheader.h inside a folder named MyFolder
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.
So there are 1 files that I want to link together, Core.h and Events.h.
Core.h is in a folder called DevEngine and the Events.h file is in a folder called Events witch is inside DevEngine.
Here are the file directorys:
Core.h = src/DevEngine/Core.h
Events.h = src/DevEngine/Events/Events.h
I have added a #include "DevEngine/Core.h" : Cannot open include file: 'DevEngine/Core.h': No such file or directory DevEngine. I don't know where I have went wrong.
I have tried: #include "../DevEngine/Core.h". That still gives me a error.
You can do #include "../Core.h".
You can also set the directories the compiler uses to search for the header files (-I option in gcc) and then use paths to those files relative to one of those directories. (See for example gcc documentation on search paths.)
This could be done differently depending on the way you are building the project.
For Visual Studio, look in this thread.
For CMake, use include_directories.
I have a file structure like this:
main.cpp --> #include <headers/f1/v.h>
headers/f1/v.h --> #include <headers/f1/i.h>
headers/f1/i.h
headers is a directory of external library.
Compiled with 'g++ main.cpp' and got file not found error:
In file included from main.cpp:11:
./headers/f1/v.h:32:10: fatal error: 'headers/f1/i.h' file not found
#include <headers/f1/i.h>
Very new to c++. Really can't figure it out. What has been wrong here? Thanks!
When including your own headers, in the same build tree, you should use quotes not angle brackets:
#include "headers/f1/v.h"
If you do get into the situation that you need <> for local files, for whatever reason, you could add the directory to your compiler's include path:
g++ main.cpp -I .
where . is the POSIX convention for "this directory".
Further reading:
What is the difference between #include <filename> and #include "filename"?
I have a folder named apt-util with header files in include directory. When I tried to compile the source code in which I include these files, it is saying :
parseFile.C:17:36: error: apt_util/unicode_utils.h: No such file or directory
In my code, I included this file like this:
#include <apt_util/unicode_utils.h>
How to resolve this error?
I am using Linux OS and compiling using g++.
If you reference a header with a relative path, use " instead of <>
#include "apt_util/unicode_utils.h"
You also seem to have a wrong path : apt_util instead of apt-util.
Give your compiler a hint about the base path of your include directories, e.g.
gcc -I/usr/local/src ...
If the directory apt_util is a subdirectory of your current working directory shouldn't you be using #include "apt_util/unicode_utils.h" instead?
My understanding is that when I build a C++ project in xcode and I have an include line in one of my C files in angle-bracket form then the C++ compiler that works with xcode looks in /System/Library/Frameworks/ to find the file. I think that because of this answer: when I use the line #include <OpenGL/gl.h> in my xcode project, where does it look for the gl.h file?
I have an SDL.h file at /System/Library/Frameworks/SDL.framework/headers/SDL.h (I downloaded the folder SDL.framework and copied it to that location with the command sudo cp -r /Volumes/SDL/SDL.framework System/Library/Frameworks)
But my include statement in one of the files in my xcode project still gives this error:
#include <SDL/SDL.h> //throws file not found
Did I properly install the SDL framework? Why doesn't xcode see it?
Under your projects Build Settings, do a search for "search". Add a header search path to the SDL directory /System/Library/Frameworks/SDL.framework/headers
Should be able to just do this after:
#include <SDL.h>
Hope that works for you.
You can also check out this link:
http://meandmark.com/blog/2012/01/using-sdl-with-xcode-4/
It's for Xcode 4, but it looks like all the pieces are there.