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:
gcc
searches in this order, while ld
searches differently?-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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With