Import Error on boost python hello program

后端 未结 4 1072
粉色の甜心
粉色の甜心 2020-12-05 18:46

include

using namespace boost::python;

struct World{
    void set(std::string msg) { this->msg = msg; }
    std::string greet() { return msg; }
    st         


        
4条回答
  •  佛祖请我去吃肉
    2020-12-05 19:22

    same as other post here

    g++ -c -fPIC hello.cpp -o hello.o
    g++ -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]
    

提交回复
热议问题