Import Error on boost python hello program Import Error on boost python hello program python python

Import Error on boost python hello program


Solved this via "No such file or directory" error with Boost Python

g++ -c -fPIC hello.cpp -o hello.og++ -shared -Wl,-soname,hello.so -o hello.so  hello.o -lpython2.6 -lboost_python

did the trick for me. I hope this is as clear as possible as i was struggling with this for about half an hour now ;)


same as other post here

g++ -c -fPIC hello.cpp -o hello.og++ -shared -Wl,-soname,hello.so -o hello.so  hello.o -lpython2.6 -lboost_python

But i want to stress the importance of the position of "-lpython2.6 -lboost_python". If you put them in front of input files (hello.o), they will be somehow ignored (not linked to the final hello.so). This is at least true for g++ (Ubuntu/Linaro 4.6.3-1ubuntu5).

To be simple, http://ubuntuforums.org/showthread.php?t=496287 suggested:

  g++ <.cpp or .o file(s)> [LDFLAGS] [LIBS] -o [appname]


Oh, I just saw this post:

help needed with boost python

and problem solved