Embedded Python Linking Problem

Alex Martelli aleax at aleax.it
Tue Feb 25 17:15:35 EST 2003


Ian Terrell wrote:
   ...
> I'm running an i686 system with Red Hat 8, using gcc 3.2 and Python
> 2.2.

Athlon, Mandrake 9.0, gcc 3.2 and python 2.2 here.


> The C++ program is:
> -----
> #include <python2.2/Python.h>
> int main()
> {
>   Py_Initialize();
> 
>   PyRun_SimpleString("print \"Hello, world!\"");
> 
>   Py_Finalize();
>   return 0;
> }
> -----
> 
> It compiles cleanly, but can't resolve linking:

[alex at lancelot leap]$ g++ hello.cc -lpython2.2
[alex at lancelot leap]$ ./a.out
Hello, world!

So the problem is, where's your libpython2.2.so ?  Mine's
in /usr/lib (thanks Mandrake;-) so I clearly have no problems
(and a small executable too):

[alex at lancelot leap]$ size a.out
   text    data     bss     dec     hex filename
   1301     380       4    1685     695 a.out
[alex at lancelot leap]$


Alex





More information about the Python-list mailing list