[capi-sig] Linking problem

ecir hana ecir.hana at gmail.com
Sun Feb 24 13:25:06 CET 2013


Hello,

I would like to embed Python 3.3, I followed the simplest tutorial here:
http://docs.python.org/3.3/extending/embedding.html

I'm on MacOS 10.8 which has Python 2.7 but I would like to embed the 3.3
version. I downloaded v3.3 binary distribution from python.org for Mac. I
unzipped the archive, took out all the headers and "Python" dynamic library
to a new folder. I then renamed the "Python" file to "python33" so that it
wont collide with installed Python 2.7. So in the folder, there are:

    embed.c
    include (folder)
    python33

Running "file python33" says:

    python33 (for architecture i386): Mach-O dynamically linked shared
library i386
    python33 (for architecture x86_64): Mach-O 64-bit dynamically linked
shared library x86_64

and embed.c is:

    #include <Python.h>

    int
    main(int argc, char *argv[])
    {
      Py_Initialize();
      PyRun_SimpleString("print 'test'\n");
      Py_Finalize();
      return 0;
    }

It compiles but when I do "gcc embed.c -I./include -L. -lpython33" it
breaks with:

    ld: library not found for -lpython33

Please, does anyone know how to make it compile? I don't want to *install*
Python 3.3 - is it possible to just extract the dynamic library from the
binary distribution and use it, like I did above? I also tried:

    DYLD_LIBRARY_PATH="." gcc embed.c -I./include -L. -lpython33

but it doesn't work.


More information about the capi-sig mailing list