After googling over the whole night i slept a bit woke up and found the solution for the following problem:
I’ve added a new static library target to my Xcode project, let’s call itt foobar. Quite supprisingly it built right away, even tought there are a lot of dirty little system dependent #ifdefs in the code.
Anyways i was really happy that i could compile it. After a while I switched the active build configuration from Debug to Release, and tried to build the whole project. Suddenly the following errors came up:
‘error: template with C linkage’
and some other error becuase it was trying to include a system header instead of my own (even though i included it with quotes e.g #include “foobaar.h”).
I switched back to Debug configuration mode – thinking that before it was working it my work now as well -.... nothing!
This is the point where i started to google and try to find out what could be the problem. You’ll get couple of pointers how this might be fixed, here’s a little list:
1) for fixing the template error, one where suggesting that i should use the:
#ifdef __cplusplus
extern C {
#include "templateerror.h"
}
#endif
wrapper because it really tries to compile as standard C instead of C++. I’ve checked the Build Console and it was telling:
bc.
/usr/bin/gcc-4.0 -x c++
so it was not trying to do that
2) for fixing the misincluding i should use -iquote option, so that path is going to be used for quoted includes.
None of these helped!
So i switched to the old console and tried the following: copied the whole gcc line as XCode tries to compile my sources (Build Result) and removed the gcc’s argument one by one, to see what is really causing here the problem.
I’ve found out that if i remove the -I*own-target-headers.hmap option, then it compiles right away. I tried to figure out how can i tweak this option in Xcode, but there was nothing about this. I was about to give up on this, when I saw the Copy Headers option of my foobar target – and of course there was all the headers that was belonging to this library. I figured I should remove all those headers from there (anyways i don’t want to copy them anywhere, since i’m trying to make here a static library after all). I tried to build again the library….. OF COURSE, NOTHING!
And here i was just sitting and thinking, when i remembered: things came up when i toggled the ‘Active Build Configuration’, so I TOGGLED IT NOW AGAIN, and guess what, IT WAS PERFECTLY WORKING!
maaaaaaaaaaaaaaaan, xcode has some serious flaws!!!
Anyways if this helped you, drop a comment, i’m really curious how many people getting into this problem as well.