Xcode 8.2 can't find header files from added search path? - c++

I am having trouble getting Xcode to find opencv header files. In the 'Build Settings' tab I added the recursive path '/usr/local/Cellar/opencv3/include' to 'Header Search Paths' and 'User Header Search Paths' and I have an include of #include "opencv2/core.hpp"
I added the path to both keys because it wasn't working for either one individually so that's just the way I have it right now. The error I get is 'opencv2/core.hpp' file not found. Any suggestions? I'm pretty sure this should be working.
EDIT 1: I also have the key 'Always Search User Paths' set to 'Yes'

My apologies to those who spent time trying to figure out what was wrong. The problem was that I had set the build settings for the UI tests target rather than the application project.
In case others come across the same mistake, This is where the target can be changed:
I don't remember ever changing it in the first place, but apparently I did at some point.
Hopefully this is helpful to the next guy that makes this simple mistake.

Related

Include OpenCV for Project in C++

I feel like this should be basic, but I can't find anything for it online. I downloaded OpenCV and can't figure out how to have my projects recognize it. When I try to include it with like
#include <opencv2/core/version.hpp>
I get the error:
"No such file or directory"
The only solution I've tried is to add /usr/include/opencv4/ to my PATH. Also, I am running ArchLinux if that is helpful to know.
So I ended up just moving the directory /usr/include/opencv4/opencv2 to /usr/include and that worked. Unless there are any ways to add directories to the list of directories that c++ checks when running the #include, this is the only way I've figured to solve it.
if you have trouble with this
#include <opencv2/core/version.hpp>
You can find more detail information on "Googling".
what I have organized shown below:
try using include "opencv2/core/version.hpp" instead of it.
right-click, then check-the-location
recheck several environment settings:
Additional Include Directories
Linker
Additional Dependencies
PATH
Try changing these three:
PATH=$PATH:/usr/bin
CPATH=$CPATH:/usr/include/opencv4
LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/lib64:/usr/lib

Xcode folders and groups confusion

I'm using Xcode (with C++) and my project layout (in the file system, not in Xcode) looks like this:
SubfolderA
-file_A_1, file_A_2
SubfolderB
-file_B_1, file_B_2
Right now I've set up this structure in Xcode via groups. And so, when I want to include file_A_2 in file_B_1, I write #include "file_A_2" in file_B_1.
Is there some way to make an inclusion look like #include "/SubfolderA/file_A_2", so that I can easily see to what directory/subfolder an included file belongs?
One way to see what's going on is to look at the Build Log and expand the line for compiling sourcefile.m. Look at the -I options being passed to the compiler.
If it's not to your liking you can add the source tree in the Build Settings > Header Search Paths to include $(ProjectDir)/srcroot and make it recursive, which saves you from adding each sub-folder individually.
In my experience this has never been necessary, however, as far as I can remember.
As far as the Xcode folders are concerned, if the top-level source folder is added then all sub-folders are automatically added when you add them to the filesystem, saving the hassle of keeping them in sync. You might need to add the top-level folder under the Source Files group for this to work, however.
Surprisingly, in Xcode's Build Settings I've added to User Header Search Paths non-recursive path to my project. This solved my problem.
I ended up here when I was having an issue with XCode while trying to include a header in a group by doing
#include "MyGroup/MyHeader.h"
Turns out the project structure and the file system weren't in sync, so I just had to remove my group from the project, put it in the correct place in Finder, then drag and drop it back into the project in the correct place and it worked for me.
I'm not sure if this is necessary or not, but I also have already set up my app's working directory because I am doing some game programming and need to be able to load in .png and make textures.

Eclipse CDT MinGW path variables

My Eclipse didn't show any console outputs.
I tested the ".exe" in the debug file of my C++ project, with wich i received an error that "libgcc_s_dw2-1.dll" was missing.
I read abit on this and i found that i could simply copy/paste that file from my c:/MinGW/bin folder to the ".exe" in the "/debug" folder of my project.
That helped me with that error but i then received the message that "libstdc++-6.dll" was missing, so i did the same again.
Now The ".exe" works fine and I get an output in my eclipse.
But now i'm afraid that i will get simillar erro's at my next build if i use some what more complex programming.
I also think that it would be very timeconsuming if i have to add those files too all of my future projects.
Question:
So my question now isn't there a way to tell eclpise that those .dll files are at "c:/MinGW/bin"?
PS.
I suspect that a similar question already exists but I wouldn't have a clue on what tags I'd have to search for.
Speacial thanks to #Deniz !
right click on "my computer" => properties .
on the right select "Advanced system settings".
open "Enviormentvariables"
search for "path"
select Edit
you'll have a list of paths, hit "end" on your keyboard to make sure you are at the end of this list.
then add ";" to close the previous path and add the path to your MinGW/bin location. (by default C:\MinGW\bin).
result in adding ";C:\MinGW\bin"

xcode -- add search path for header files - get c++ to print header search paths?

I know this is a basic question, but I've been stumped for a few hours (pretty embarassing) and I'd like to get past this.
For future reference, is it possible to get c++ to print the header search paths it is searching?
My problem is that I keep getting path error problems, as shown below.
And I've tried updating the search paths in xcode for the project as follows:
where cv.h has the following info page:
The code I am trying to run is this:
What am I missing here?
BEFORE YOU MARK AS DUPLICATE:
I've already looked at previous posts on the topic, none of them have been helpful. I'll try to update with pictures etc. so updating path dependencies in xcode is fully covered in the future.

Working with Box2D/Cocos2D in an external iOS project

I have followed the instructions as per this article and have been working with Cocos2D without much issues. Recently, I tried including the Box2D headers to try some physics like so:
#import "Box2D.h"
This resulted in a lot of errors where the Box2D.h file could not include the rest of the header files:
../cocos2d-iphone-0.99.5/external/Box2d/Box2D/Box2D.h:34:0 ../cocos2d-iphone-0.99.5/external/Box2d/Box2D/Box2D.h:34:37: error: Box2D/Common/b2Settings.h: No such file or directory
That's the first error and the rest of the 23 are like that, but for the different headers in Box2D.h.
I have already added the projects/targets to the current project as per the instructions in the article, so my project currently looks like this:
Also, I have attempted to remedy this by selecting all .m files in my project and setting the file type to sourcecode.cpp.objcpp but do not think that this is the issue. I am certain that under the User Header Search Paths build setting, the folders where these headers are stored are added. If it weren't, Cocos2D wouldn't be able to compile either.
What am I doing wrong?
I don't know if this is immediately obvious to other programmers, but I fixed this by checking the Always Search User Paths setting in the target settings. Hope it helps someone else.
Another solition for me is removing blank characters from directory names. Forexample if your project folder such as
"user/prj 01"
change it to
"user/prj01".