Using distutils for embedding -- was: Re: Newbie: Undefined reference when initializing Python

Gerhard Häring gh_pythonlist at gmx.de
Thu Mar 14 11:38:29 EST 2002


Le 14/03/02 ? 10:41, henrikb666 écrivit:
> --- In python-list at y..., Michael Hudson <mwh at p...> wrote:
> > You need to link to Python; there should be a "-lpython" in there
> > somewhere (and probably a "-L/some/path/or/other/" too).
> The -l entry in the Makefile should point to the directory with
> the libpython2.2.a file, right?

There should be an -L entry pointing to the directory containing the
libpython2.2.a file. And there should be a -lpython2.2 entry, too. -L points to
the library directories. -lsomething means that this library should be linked
against.

> When the file is placed in /home/pos/Python-2.2, what should the
> entry look like exactly, because I tried this without success
> (yes, I know I am a Linux newbie!):

Erh. Have you installed your Python 2.2 at all? I mean, did you make the "make
install" step? This is necessary. This installs Python 2.2 at the place you
told you specified with --prefix in the configure step. If you didn't specifiy
any --prefix, it's installed into /usr/local by default.

Out of interest, I've tried to hack a Makefile that uses distutils. It would be
nice if I could get some feedback on it, as this or an improved version could
possibly solve this problem once and for all.

Here it is, playing tricks with distutils again (Python should point to the
Python executable you want to use, like python, python2.1, python2.2,
/usr/local/cvspython/bin/python or whatever):

PYTHON=python
PYFLAGS=`$(PYTHON) -c 'from distutils.sysconfig get_config_var; var = get_config_var; print " ".join([var("LIBS"), var("SYSLIBS"), var("LDFLAGS"), "-L"+var("LIBPL"), "-I"+var("INCLUDEPY"), "-lpython"+var("VERSION")])'`
embed: embed.c
	$(CC) -o embed embed.c $(PYFLAGS)

Gerhard
-- 
This sig powered by Python!
Außentemperatur in München: 10.9 °C      Wind: 3.3 m/s




More information about the Python-list mailing list