XCode import statement and subdirectories - c++

I'm running into an import issue that as a relative newcomer to the Objective-C/C++/XCode world I haven't seen before.
I'd like to include this library with my project: https://github.com/jdkoftinoff/jdksmidi
But, it seems like no matter how I try to add it to the project, I get errors when I try to import:
#import "jdksmidi/world.h"
(No such file or directory)
I can import without the jdksmidi subdirectory, but since inside all of the headers included with the library, the author uses the same syntax with the subdirectory, I'm stuck.
Simplified question: how do I add the library to my project so that I can use the #import "jdksmidi/___FILE____.h" format and not throw compiler errors?
Thanks

You probably need to adjust your User Header Search Paths (USER_HEADER_SEARCH_PATHS) in your build settings. Make sure that the folder containing jdksmidi is in the path. Hope that helps.

you need add your jdksmidi/world.h file in project, just drag'n'drop it into your groups & files section. Or you can use #include directive

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

VSCode: How to add include path of project subDirectory?

I just started using VSCode on linux Ubuntu environment and for past one day trying to include some header files from a sub-Directory (the project screen shot is shown below).
I have tired adding the header file path in include path but showing error.(Image below)
I also tired by provided complete path e.g. /home/user/Work/Cpp_Test_Project/OpenFace/FaceAnalyser/include/ still it couldn't find the header file.
Also, If I try to include the header with local path e.g.
#include <OpenFace/LandmarkDetector/LandmarkCoreIncludes.h
then all the internally linked header file doesn't work.
any help will be highly appreciated.
The c_cpp_properties.json file is for configuring IntelliSense. The compiler you are using does not read from this file, so you will need to configure the include path for that separately. From what you have posted, it is unclear how you have set up your build.

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.

xcode includes of header files

I am trying to compile a sample project for a browser plugin (http://pushingtheweb.com/2010/06/boilerplate-for-a-npapi-plugin/) using xcode 3.2.6 on Snow Leopard.
I have never used xcode before.
When I try to build I get an error with an include (AE/AERegistry.h: No such file or directory)
When I click on the file it takes me to the header file AE.h (which is in folder /System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/Headers) and has the lines:
ifndef __AEREGISTRY__
include <AE/AERegistry.h>
endif
Firstly I dont know how to find out why AE.h is included in the build as I cant see it "included" anywhere.
Secondly why cant it find AERegistry.h which is in four separate locations on the computer?
I manually added one of the folders to the Header paths but it made no difference.
Why is it AE/AEReistry when it is not in a folder AE?
Thanks for any help
George
You'll have to go into the build settings, find "compiler flags"(CFLAGS), and add something like:
-I/System/Library/Frameworks/CoreServices.framework/Versions/A/Frameworks/AE.framework/Versions/A/Headers
And then do:
#include <AERegistry.h>

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".