简体   繁体   中英

Xcode cannot find #Include<> header

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.

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM