Right, I know this is a very stupid question, but I have no luck with w/e i'm trying to do.
I'm trying to use the objdetect.hpp header file, so I've included the folder C:\OpenCV2.1\include\opencv2\ aswell as C:\OpenCV2.1\include\opencv and a whole bunch of other libraries and dlls when I was following the instructions on http://opencv.willowgarage.com/wiki/VisualC%2B%2B_VS2010
But the openCV version in that tutorial were outdated and doesn't even have the objdetect.hpp file. So I went to download the latest one (OpenCV 2.4.0), but now when I complie it, it gives me an error C1083: Cannot open include file: "opencv2/core/core.hpp" No such file directory.
Am I suppost to put all the OpenCV folders/files in the same directory as my C++ project? Or how do I fix it? I've tried putting it in the same place as my C++ project, but when I do a #include "../" the folder doesn't appear.
Again, I know this is a stupid question, but please help.
Let me know if anyone require more info coz I'm not too sure whatelse to put.
Thanks
The best way to manage changing directories for include files is with the compiler options. Im better at linux and g++, where you would just specify different include path locations with -I attributes.
Its generally considered bad practice to use relative and absolute paths in the #include statements. Module paths are ok #include <sys/time.h>, where sys could be considered the module. Include the file with just its name and possibly the module, then handle the location with the compiler options.
Related
I've just started using the Atom editor, and tried setting up a simple C++ file to test it out.
Tried to #include a boost file, but got an error that the path couldn't be found. Had to use the absolute path in order to properly include the directories.
Is there a better way of adding my boost folder? Tried setting up a environment path for it but couldn't use it with #include. As a hail-mary I tried adding the boost path to my PATH, but still nothing.
The top of my .cpp file:
#include <C:\Program Files\Boost\boost_1_73_0\boost\beast\websocket.hpp> //how I currently have to do it
#include <{BOOST_PATH}\boost\beast\websocket.hpp> //how I was hoping to do it
Still very new to Atom and C++, any help is very appreciated.
E:
Tried the suggestions with not much work, though got it to somewhat work using the -I flag for GCC compilation. Having issues with an error undefined reference to `__imp_WSACleanup' but it's too late for that now. Cheers for the help.
The src file is broken down into different libraries and inside each one is the xxx.c and its xxx.h counterpart. In almost all of my classes I get file not found errors on the first import statement for the .h file. I deleted the "library/" and it removes the error. I was wondering if there is an easier way to to this other than going through each of the 1000 classes and doing this for each of the import statements. I have already included sdl framework in the "Link binaries with Libraries". Please help im lost.
Try using the USER_HEADER_SEARCH_PATHS for paths you want searched for #include "..." You can find this option in Build Settings of Target.
You can specify path like this: $(SRCROOT)/Subfolder/subfolder
I want to include a header file. I am working in a C++ environment, (C++11, Windows OS, Netbeans 7.3.1 IDE, Cygwin_4.x tool collection). I do not know how I setup the environment/IDE (I did it 6 months ago). I do not understand the fundamentals of the C++ build process or Cygwin related issues either, so I might have to fill in the gaps with some other references/documentation (on what specifically, I'm not sure).
My ultimate objective is to be able to include header files using a syntax that does not require the full file path. I want to write something terse, like:
#include "src\stuff\blah.h" //or even better: #include "blah.h"
The only way I can get my program to compile at all is by using the full file path, like this:
#include "C:\NetBeansProjects\Project1\src\stuff\blah.h"
And, I can only compile once using the full path. If I try to rebuild, it will bomb with the *** multiple target patterns. Stop. error. There are workarounds for this error; those being either 1) deleting the build and dist folders between each rebuild (yikes?), or 2) following this 16 step setup process.
I do not want to follow either of those workarounds because they do not appear to deliver what I want. How can I setup my environment to achieve what I want...of being able to include header files without using full paths?
Thanks to DanielKO for this answer.
In my case, I was able to include with the syntax:
#include "../stuff/blah.h"
I did not have to configure anything under the "Code Assistance" section for the C++ compiler.
All of my code is under "src" as the parent directory in my NetBeans project. It seems that the full path of the file is not required, and the only directory that must be referenced is the lowest level subdirectory (in my case, "stuff").
In NetBeans I've added the path to the list of libraries:
Go to Properties->Select C++->Select 'include libraries'->'Add'
Now: Add the path of the project folder with option "absolute"
Go to Properties->Select C++->Select 'Additional library directories'->'Add'
Now: Add the path of the project folder with option "absolute"
It's very obscure to me why the project doesn't recognize "own" header files.
I have imported my project from windows to mac and Is using xcode to compile the project.
I have managed to fix most error and bugs from the porting process but there is one bug/error I am unable to determine why its not working as it should. This probably due to my lack of knowledge of xcode but was wondering if anyone is able to help me with this problem.
The problem is this;
I have a two sub folders in my project, once called include and another called source. Of course include contains all the header files and source contains all the cpp files and such.
Example:
Root/
Include/
Header.h
Source/
test.cpp
Now in the build settings in the xcode project, I have added $(SRCROOT)/Include/ in the Header Serach Paths. So therefore I presume that xcode will include any header files in the Include folder.
So in the test.cpp class I add #include "Header.h". When I click build I get an error saying "'Header.h' file not found".
Im not entirely sure what I am doing wrong, of course I can do this for example - #include "../Include/Header.h" but that's going to be a pain going through all the cpp files in my project (which is a lot).
I was just wondering if anyone else came across this problem?
Thanks for reading.
In general you need to add the headers to the User Header Search Paths, which if you search the help in XCode will give you the format you need to pass the directory as.
I'm trying to get Xcode to import the header file for Irrlicht.
#include <irrlicht.h>
It says "Irrlicht.h. No such file or directory". Yes Irrlicht.h with a capital I, even though the #include is lowercase.
Anyway I added "/lib/irrlicht-1.6/include" in the header search paths for the Xcode project, yet it still doesn't find it.
The only thing I've tried that does work is:
#include "/lib/irrlicht-1.6/include/irrlicht.h"
This is a bit ridiculous though, #include should work, I don't understand why it isn't working.
Update (here are more details on the error):
/lib/PAL/pal_benchmark/palBenchmark/main.h:31:0
/lib/PAL/pal_benchmark/palBenchmark/main.h:31:22: error: irrlicht.h: No such file or directory
I figured this out. Perhaps someone can comment as to why this is the case.
The Header was located in this directory:
/lib/irrlicht-1.6/include/
If I added that path to: "Header Search Paths" Xcode still wouldn't find the path when I built the project.
Solution: Add the header path to: "User Header Search Paths" instead.
It boggles me why I had to do this, as I frequently add my header paths to "Header Search Paths" and then #includes just work. Hopefully this can help someone else who gets this same issue.
Both
#include <irrlicht.h>
#include "irrlicht.h"
should work as long as the "-I" argument to gcc includes the path of the directory enclosing the header file. If irrlicht.h is part of /usr/include the "-I" option is no longer required.
Rather than explicitly adding include paths to your project settings, an easier and more convenient solution for this kind of situation is to just drag the directory containing your .h files (/lib/irrlicht-1.6/include in this case) into the project files pane. This adds the headers to your project of course, and makes it easy to browse them and search for symbols, etc, and it also adds the directory path to gcc compiles, so that you don't have to manage include paths explicitly.
and furthermore, a flat file hierarchy isn't what you want. Dragging files into Xcode flattens your hierarchy. What about for example when you want to have multiple Targets, with a "TargetName/settings.h" file for that target. you'll have many settings.h files that you need to keep unique via its folder name.
I understand that this is an old post, but it does rank quite high on Google, so I thought I would add some information
Under XCode 3.2.6, I had an issue where XCode could not find a header file. It turns out that one of the filepaths included a space in it, and XCode interpreted it improperly.
For example: With a path like "Users/Username/Desktop/Project/Some Headers"
Here was the excerpt from the GCC Commandline: "-I/Users/Username/Desktop/Project/Some" "-I/Headers"
To see your build log provided by XCode, there is a good tutorial here: How do you show Xcode's build log? (Trying to verify if iPhone distribution build zip was created correctly.)