Embedded Python Linking Problem

Ian Terrell kife00 at yahoo.com
Wed Feb 26 13:29:28 EST 2003


Alex Martelli <aleax at aleax.it> wrote in message news:<U827a.321905$AA2.12075069 at news2.tin.it>...
> So on the end:
> 
> [alex at lancelot leap]$ g++ hello.o 
> /usr/local/lib/python2.2/config/libpython2.2.a -ldl -lutil -lpthread

Adding those linking options does do the trick:

$ g++ -O3 hello.cc -o hello -L/usr/lib/python2.2/config/ -lpython2.2
-ldl -lutil -lpthread
/usr/lib/python2.2/config//libpython2.2.a(posixmodule.o): In function
`posix_tmpnam':
posixmodule.o(.text+0x3977): the use of `tmpnam_r' is dangerous,
better use `mkstemp'
/usr/lib/python2.2/config//libpython2.2.a(posixmodule.o): In function
`posix_tempnam':
posixmodule.o(.text+0x385e): the use of `tempnam' is dangerous, better
use `mkstemp'
$ ./hello
Hello, world!

Of course, it looks like my executable is a tad bigger than yours,
also. =)
$ size hello
   text    data     bss     dec     hex filename
 628163  115000   12256  755419   b86db hello

It definitely is interesting why Mandrake creates the .so and Red Hat
doesn't.  Thanks for all the help though!

Ian




More information about the Python-list mailing list