Mikhail Edoshin
Mikhail Edoshin

Reputation: 96

GCC Mac OS X framework search path: /System/Library before /Library?

I'm trying to compile a project on Mac OS X that links to Python. I have Python 2.7 framework in /Library/Frameworks. I compile for Mac OS X 4, so I also have Python 2.3 in /Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks. If I invoke gcc with -F/Library/Frameworks and peek at what it does with -v, I see the following:

ignoring duplicate directory "/Library/Frameworks"
  as it is a non-system directory that duplicates a system directory
<skipped>
#include "..." search starts here:
#include <...> search starts here:
 <skipped>
 /Developer/SDKs/MacOSX10.4u.sdk/System/Library/Frameworks (framework directory)
 /Developer/SDKs/MacOSX10.4u.sdk/Library/Frameworks (framework directory)

I.e. it ignores my /Library/Frameworks because it's a duplicate (of the last path, which is a symlink to /Library/Frameworks) and then finds its own Python 2.3 framework before my 2.7.

I understand how to work around this (e.g. use -I with a full path to the include directory), but I'm somewhat puzzled by the search order. E.g. the linker (ld) seems to search System/Library and Library in different order. I've tried to check manuals and Google, but, apparently, my skills are too low :)

I guess my questions are:

Upvotes: 5

Views: 8950

Answers (1)

Mike Stump
Mike Stump

Reputation: 41

I think it is a bug that gcc and ld have a different ordering between the two. You can have that fixed by filing a bug with llvm and/or Apple. If Library were first, I think this would then do what you want.

Until then, you can do this:

$ mkdir Frameworks
$ ln -s /Library/Frameworks/Python.framework Frameworks
$ gcc -FFrameworks -E t.c

Upvotes: 4

Related Questions