I am trying to #include "physics/everything.hpp" in one of my project files, however I get the error: "No such file or directory"
I am using codeblocks, and that directory definitely exists, because it is shown in the left hand project browser pane.
Any ideas?
Use Settings -> Compiler & Debugger Settings -> Search Directories to add root of your project to include dirs. You should do it to be able to include files not by relative paths but by relative to project root.
Apologies everyone: I should have done this:
#include "./../physics/everything.hpp"
The file doing the including was in a sub-directory itself... (Rookie error)
Related
I am refactoring my Visual-Studio-C++ project to use a folder structure rather than the filters in Visual Studio but I have noticed that when I try to include a file, it will use the current directory of that file so my includes look something like...
#include "../../server/IGameServer.h"
This is quite problematic when I refactor and move things around as I then have to go into each file and change their includes...
Is there a way to make every file start from the base directory no matter where the current file is, or a way to include the folder path so I can just use
#include "IGameServer.h"
(1) Go to project properties:
And add folders to "Addiotional Include Directories". ...Make sure that you aply to "All Configurations" (Debug, Release, etc.) and "All Platforms" (X86, X64).
--
(2) Click on that line + one more click on right side, on the down-arrow) & click Edit.... It opens a dialog that looks like that (I already added some folders in this example):
I am a "very" beginner of OpenCV. I just downloaded it for my Windows and extracted.
I have read this post: http://opencv-srf.blogspot.ro/2011/09/capturing-images-videos.html about how to read webcam and I copied and pasted the code in a C++ file I created in "include" folder of OpenCV extracted archive.
When I try to run the program I get this error: Error in: /opencv/build/include/opencv2/highgui/highgui.hpp - opencv2/highgui.hpp: No such file or directory.
What should I do?
Thank you all!
EDIT
I opened: "/opencv/build/include/opencv2/highgui/highgui.hpp" and I can see that it includes this path "opencv2/highgui.hpp". If I change it to "../highgui.hpp" it works but I get other errors like this for other files... What should I do?
The problem is that you are not supposed to create your "cpp" file in the OpenCV "include" directory. You need to create it in a separate directory and then add OpenCV "include" as additional include directory for the compilation step.
The way to achieve this depends on your C++ development environment. If you are using Visual Studio, then you need to open project property pages, go to "C/C++ -> General" and add the path to OpenCV "include" directory to "Additional Include Directories". In case of some other compiler/IDE, you can find out how to do this by reading the corresponding documentation.
Running xCode 4.6.3
I have my X11 header files stored in the following path:
/Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11
I have a .cp file and include X11/X.h
Error shows X11/X.h file not found.
Have tried putting path /Library/Frameworks/Tk.framework/Versions/8.5/Headers/X11 where these files are located under Targets>Search Paths>Header Search Paths but with no success.
Can someone explain where to put this path so that xCode can find the file?
\
I had used the incorrect search path. There are two of them in Xcode.
To get these files recognized, I clicked the Project Name > Target Under Build Settings I went to Search Paths > User Header Search Paths > /Users/MYUSERNAME/Documents/MESA/Mesa-9.1.5/include/
Also selected the recursive option. This allowed Xcode to see the files.
I'm pretty new to C++ and Eclipse in general so I apologise if I'm missing something fairly obvious.
The problem I'm having is that I'm trying to include a header file in one of my source files but they're in different folders in my project directory. I have no idea how I should be including them. I've uploaded an image showing my problem with the header file I want to include highlighted.
If someone could tell me what '#include' statement I should be using them that would be brilliant.
Thanks!
There are a couple of different options to make this work. Simplest is to change the #include to
#include "../Statistics/Statistics.h"
This will work without any other modifications. However, if you move either file, or somehow change the relative path between the two, this will break.
Alternately, you can add the path to the Statistics folder to your compiler's include file search path. Right click on the project name, select Properties -> C/C++ Build -> Settings and then find the includes files path option for your compiler. For g++, it is -I<path/to/include/folder>. Adding this will make the #include statement work as you currently have it.
A very similar option to the second one is to add the path to the src folder (instead of the Statistics folder) to the includes search path. In this case, you'll have to change the statement to
#include "Statistics/Statistics.h"
When you create subfolders in your src folder then each cpp file is compiled in that folder it is located in. Thus, any "" includes need to specify the relative path to get from that folder to another.
In your case, to get from inside the FileInOut folder you need to go back one level and then into the Statistics folder
eg
#include "../Statistics/Statistics.h"
Another alternative is, if you are keeping your includes in your src directory, to add the src directory to the include path. Now when you include you need only specify the path from the src root.
eg.
#include "Statistics/Statistics.h"
I'm trying to port over a project I initially wrote in Windows to OS X and am having some difficulty with the header search paths.
I've used user search paths to include by source folder "project/src/core/"
Under core, I have, for example:
"projects/src/core/sys/sys_sdl.h"
which tries to include
"projects/src/core/render/opengl_render.h"
with the directive:
#include "render/opengl_render.h"
I've tried tons of different options, but I can't get seem to get Xcode to find the file unless I change it to "../render/opengl_render.h"
Is there something I'm missing here in the settings to get it to recognize relative paths to the header search paths?
Did you try setting the User Header Search Path to $SRCROOT/..? $SRCROOT is the directory that contains the target's source files, so $SRCROOT/.. should be the directory above that, which I think is what you want.
A related question (How do I print a list of "Build Settings" in Xcode project?) shows a useful command that makes it easy to see all the build settings and the variables they modify:
$ xcodebuild -project myProj.xcodeproj -target "myTarg" -showBuildSettings