Python embedding & question about autoconf and dynamic linking
Mads Bondo Dydensborg
madsdyd at challenge.dk
Mon Oct 1 04:21:17 EDT 2001
On 29 Sep 2001, Titus Brown wrote:
> In article <mailman.1001714851.11810.python-list at python.org>,
> Mads Bondo Dydensborg <madsdyd at challenge.dk> wrote:
> >Hi there
> >
> >I am trying to use Python as an embedded interprenter. Whilst it is quite
> >easy to understand the C interface, I have found it _very_ hard to figure
> >out what flags I need to pass to the linker to get a succesfull
> >compile. It seems to depend rather heavily on a lot of parameters.
>
> Yep.
At least I have that right ;-)
>
> >So, my first question is if there are any autoconf macros out there that
> >will work for me, sort of like a AM_PATH_SDL macro? I have been searching
> >around, and found one from on of the KDE libs, but it seems to break
> >rather quickly for everything else than Python 1.5 (which it seems to be
> >only partly succesfull in anyway).
>
> I haven't found one in distutils, either, which seems like a natural
> place for them.
>
> Please let me know if you get a list sent to you privately; I'm very
> interested in this for 'configure'ing PyWX...
No luck so far. (I am quoting most of my original post in case someone in
knowledge will notice).
I will continue to hack on the KDE_CHECK_PYTHON script - what are you
using for PyWX?
>
> >My next question is with respect to dynamicly linking to the python
> >interprenter, when embedding it. All info I have been able to find, points
> >towards linking statically with libpython.<version>.a - however, this adds
> >about 660KB to my application, and in general I would much rather link to
> >a .so file - but I have not been able to find "such a beast" or
> >instructions on how to build one. Is it possible? Or is there a clever
> >way arond this kind of problem that I - beeing a clueless newbee - have
> >totally overlooked? (Maybe some weird extension trickery?)
>
> There used to be an explicit FAQ entry on this, in
>
> http://www.python.org/doc/FAQ.html
>
> entry 3.11 or thereabouts. It's gone now ;(.
At least I didn't overlook it :-)
> For older versions, you should be able to do something like this:
>
> make CFLAGS=-fpic
> mkdir .shared
> cd .shared
> ar xv ../libpython.a
> gcc -shared -o ../libpython.so *.o
Hmm. So, I should actually be able to create a .so on an endusers machine,
_if_ the original python installation was built with -fpic. Otherwise I
have to recompile the python installation.
Not a nice thing. Are there any particular reason that python does not
"come as a so" on Linux and Solaris? (Or other .so enabled platforms).
Mads
--
Mads Bondo Dydensborg. madsdyd at challenge.dk
You know you're a Linux geek when...
You keep track of your highest uptime, and try to break your record.
- segfault
More information about the Python-list
mailing list