Linking embedded python?

Andrew Sobala andrew at sobala.net
Thu Dec 26 13:00:37 EST 2002


(please keep me Cc'd if you reply to this mail)

Hi,

I'm trying to work out how to make my C program dynamically link to the
python library in autoconf. At the moment I'm using (modified) code I
found in someone else's autoconf by googling:

AC_PATH_PROG(pythonpath, python)

if test "_$pythonpath" = _ ; then
    echo "*** Python not found *** " 1>&2 ; exit 1;
else
    PY_PREFIX=`$pythonpath -c 'import sys ; print sys.prefix'`
    changequote(<<, >>)dnl
    PY_VERSION=`$pythonpath -c 'import sys ; print sys.version[0:3]'`
    changequote([, ])dnl
fi

if test -f $PY_PREFIX/include/python$PY_VERSION/Python.h; then
    LDFLAGS="$LDFLAGS -L$PY_PREFIX/lib/python$PY_VERSION/config"
    echo "-L$PY_PREFIX/lib/python$PY_VERSION/config"
    AC_CHECK_LIB(libpython$PY_VERSION, Py_Initialize, AC_SUBST(LDFLAGS),
		AC_MSG_ERROR([*** libpython not found *** ]))
    CFLAGS="-I$PY_PREFIX/include/python$PY_VERSION $(CFLAGS)"
else
    AC_MSG_ERROR([*** Python.h not found *** ])
fi

which isn't working. What am I doing wrong?

Many thanks for your help.

-- 
                 Merry Christmas,

                               Andrew

-----BEGIN GEEK CODE BLOCK-----
Version: 3.1
GS/M d--(-) s: a17 C++(+++) UL+ P++ L+++ E--- W+>++ N(-) o? K? w--(---) !O M V-
PS+ PE Y+ PGP+>++++ t@ 5-- X- R tv-@ b++++ DI+++ D>---- G- e- h! r--- y?
------END GEEK CODE BLOCK------





More information about the Python-list mailing list