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 w开发者_如何学Goork 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:
- Is this a normal behavior and why
gcc
searches in this order, whileld
searches differently? - Are there any framework-savvy methods to solve this, or I have to use the plain old
-I
flag?
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
精彩评论