[C++-sig] Problem with importing shared library into Python
Stefan Seefeld
stefan at seefeld.name
Fri Nov 25 21:05:35 CET 2011
On 11/25/2011 02:51 PM, Edgardo C. wrote:
> Hello to all again and I really appreciate the help. Finally it works
> now !!!!!!!!!!!!!!!
Good !
>
> Unfortunately i happened just 10 minutes before leaving the office and
> until Monday I will not touch again the code.
> @Anders: I will try what you suggest on Monday.
>
>
> What I did was:
>
> $ g++ -c phonebook_wrap.cpp -I/usr/include/python2.7
> $ g++ -shared -o phonebook.so phonebook.o phonebook_wrap.o
> -lboost_python -L/usr/bin/python.27
That last argument ("-L/usr/bin/python.27") doesn't make any sense. You
should remove it.
>
> Previously I used variables to access the folder (header and
> libraries), now I use the folder explicitly. Now I am compiling
> against the boot libraries installed using synaptic and against the
> python executable located in /usr/bin/python.27.
> Honestly I expected to compiled against -lpython, but there is not
> python library like "libpython ... .so":
As I said in my last mail, you shouldn't need to link against the Python
runtime itself when building extension modules, as it will already be
loaded by the interpreter.
>
> $ g++ -shared -o phonebook.so phonebook.o phonebook_wrap.o
> -lboost_python -lpython
> /usr/bin/ld: cannot find -lpython
> collect2: ld returned 1 exit status
>
>
> I compiled against the executable, which is an ELF file and shared
> library as well, as noticed after running "file" command and it worked
> perfectly.
That doesn't make sense. You can't link against an executable. The link
command likely succeeded simply because it already found all symbols it
needed without that. Use `ldd phonebook.so` to see what libraries your
module depends on.
Regards,
Stefan
--
...ich hab' noch einen Koffer in Berlin...
More information about the Cplusplus-sig
mailing list