[Pythonmac-SIG] locating Python.h
Michael VanLandingham
m.vanland at gmail.com
Wed May 14 22:43:42 CEST 2008
If you're using Xcode, you just #include <Python/Python.h> in your
source file, then add the Python framework to your project (in Xcode,
right click on your project file in the "Groups & Files" pane, select
"Add->Existing Frameworks..."). You might need to configure the build
rules to make sure the right version of the framework is found first,
but on my system, this just worked.
If you don't add the framework to the project, you get the linker
errors that you described.
If you're not using Xcode, and instead are using gcc on the command
line or makefile, then you need to add the right flags so that it can
find the framework, etc.
-mv
On May 14, 2008, at 8:49 AM, Feat wrote:
> At 10:53 +0100 2008/04/05, Matthias Baas wrote:
>> Just for the record, the distutils have a function that returns the
>> include path:
>> >>>import distutils.sysconfig
>> >>>distutils.sysconfig.get_python_inc()
>>
>> So if you really need to know the include path for some reason, you
>> should use this function as it is platform independent. But as was
>> said above, when compiling an extension module adding this path
>> manually is not required.
>
> Thanks: my next step also involves including Python.h, as documented
> in section 5.1 Very High Level Embedding :
>
> [http://docs.python.org/ext/high-level-embedding.html]
>
> The problem is this header file does not define the required symbols
> for the C code example at the above link :
>
> collect2: ld returned 1 exit status
> /Developer/usr/bin/../libexec/gcc/i686-apple-darwin8/4.0.1/ld:
> Undefined symbols:
> _Py_Initialize
> _Py_Finalize
> _PyRun_SimpleString
>
> I've unsuccessfully tried all of the Python.h files I could find in
> my tree...
>
> Does anybody know how to link such a simple program properly?
>
> Or merely give me a clue about what I'm doing wrong?
>
> _______________________________________________
> Pythonmac-SIG maillist - Pythonmac-SIG at python.org
> http://mail.python.org/mailman/listinfo/pythonmac-sig
More information about the Pythonmac-SIG
mailing list