views:

946

answers:

3

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
+1  A: 

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.

diciu
I tried that also, it didn't work.
Brock Woolf
it does work - are you sure there's a "-I /lib/irrlicht-1.6/include" argument to gcc when XCode compiles your project?
diciu
I don't know about XCode, but a Standard compliant compiler should treat the two forms as effectively the same - the difference is in the order of places each looks in.
anon
@Neil - you're right - I've just test with gcc (called by XCode) and both variants work if the "-I" option is correctly set.
diciu
I thought adding the path to "header search paths" effectively did this: "-I /lib/irrlicht-1.6/include" ? Anyway I already knew what you were trying to say, there seems to be some weird issue where this isn't working as you would normally expect
Brock Woolf
It does - there's something else wrong. Are you sure you're editing the search paths for the current build option? (i.e. it might be you're editing for Debug and running Release).
diciu
Yes. I'm editing for "All configurations". Oh, I just figured out the problem. Cheers for your help +1, I'll post the answer in a sec.
Brock Woolf
+3  A: 

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.

Brock Woolf
A: 

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.

Paul R
Your right, dragging in the header directory normally works. Except that I tried it and it didn't work.
Brock Woolf