Embedded Python Linking Problem
Alex Martelli
aleax at aleax.it
Wed Feb 26 07:10:28 EST 2003
Ian Terrell wrote:
> Jp Calderone <exarkun at intarweb.us> wrote in message
> news:<mailman.1046211133.15312.python-list at python.org>...
>> Try: g++ hello.cc -o hello -L/usr/lib/python2.2/config/ -lpython2.2
...
> dynload_shlib.o(.text+0x1ca): undefined reference to `dlopen'
...
> /usr/lib/python2.2/config//libpython2.2.a(posixmodule.o): In function
> `posix_forkpty':
> posixmodule.o(.text+0x188f): undefined reference to `forkpty'
> collect2: ld returned 1 exit status
>
>
> Which just brings a whole new slew of linking errors. =)
Yes, I can reproduce that. Now, a -ldl easily fixes the
lack of dlopen and so on -- but forkpty &c SHOULD be in
the standard libc, I think, so I'm puzzled. Apparently
you need a -lutil to fix those -- can't find it in the
docs, but it does seem to work. Then there's pthread_* --
THAT one requires a -lpthread ...
So on the end:
[alex at lancelot leap]$ g++ hello.o
/usr/local/lib/python2.2/config/libpython2.2.a -ldl -lutil -lpthread
/usr/local/lib/python2.2/config/libpython2.2.a(posixmodule.o): In function
`posix_tmpnam':
/home/alex/Python-2.2.2/./Modules/posixmodule.c:4505: the use of `tmpnam_r'
is dangerous, better use `mkstemp'
/usr/local/lib/python2.2/config/libpython2.2.a(posixmodule.o): In function
`posix_tempnam':
/home/alex/Python-2.2.2/./Modules/posixmodule.c:4455: the use of `tempnam'
is dangerous, better use `mkstemp'
[alex at lancelot leap]$ ./a.out
Hello, world!
no idea about how to remove THOSE linker warnings. But the resulting
executable does seem to work. Now, it WOULD be nice to find out where
the need for those -ldl -lutil -lpthread is documented -- and how
Mandrake goes about building a .so and thus a tiny executable rather
than what the .a gives:
[alex at lancelot leap]$ size a.out
text data bss dec hex filename
623959 116252 11524 751735 b7877 a.out
[alex at lancelot leap]$
but I guess one could just study Mandrake's RPM's patches and
sources (sorry, no time to do that myself right now...).
Alex
More information about the Python-list
mailing list