Hello to all again and I really appreciate the help. Finally it works now
!!!!!!!!!!!!!!!

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

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":

$ 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.
Now I can import the phonebook.so from Python and run all the code. I still
want to review all what I did again because there is something that is not
clear what went wrong. Until Monday I would not be able to touch the code
again, but thanks a lot for all your suggestions, I really appreciate it.
Keep you informed on Monday.

Have a nice week end to you all,
Cheers,








2011/11/25 Anders Wallin <anders.e.e.wal...@gmail.com>

> > Hope this can help better to understand (maybe) what is going on. Again,
> I
> > follow the same procedure after installing the precompiled packages from
> > Ubuntu using synaptic, and the same error. Hope that somebody can help.
>
> FWIW with this CMakeLists.txt the example-code from the book compiles
> and runs fine on my Ubuntu 11.10 system:
> http://pastebin.com/YrWVEmxX
>
> If I run make with "make VERBOSE=1" it gives the following output
> (this might help if you don't want to use cmake...):
>
> /usr/bin/c++   -Dphonebook_EXPORTS -fPIC -I/usr/include/python2.7
> -o CMakeFiles/phonebook.dir/phonebook.o -c
> /home/anders/Desktop/apibook-apibook-tip/11_Scripting/python/phonebook.cpp
>
> /usr/bin/c++   -Dphonebook_EXPORTS -fPIC -I/usr/include/python2.7
> -o CMakeFiles/phonebook.dir/phonebook_wrap.o -c
>
> /home/anders/Desktop/apibook-apibook-tip/11_Scripting/python/phonebook_wrap.cpp
>
> /usr/bin/c++  -fPIC    -shared -Wl,-soname,phonebook.so -o
> phonebook.so CMakeFiles/phonebook.dir/phonebook.o
> CMakeFiles/phonebook.dir/phonebook_wrap.o -lboost_python
>
>
> hth,
> Anders
> _______________________________________________
> Cplusplus-sig mailing list
> Cplusplus-sig@python.org
> http://mail.python.org/mailman/listinfo/cplusplus-sig
>
_______________________________________________
Cplusplus-sig mailing list
Cplusplus-sig@python.org
http://mail.python.org/mailman/listinfo/cplusplus-sig

Reply via email to