boost

deepest1 dReEeMpOeVsEtT1H at IgSmail.com
Thu May 29 09:53:51 EDT 2008


Hi everybody.

I'm trying to use boost, but just don't know how to set it up.

My os is winXP (installed on disk D).
Python is installed in D:\Python25
MigGW compiler is installed in D:\MinGW (i downloaded it because djgpp 
is making much more errors with bjam)

I have downloaded boost_1_35_0.zip and boost-jam-3.1.16-1-ntx86.zip,
extracted boost_1_35_0.zip to D:\Program Files (so I have now D:\Program 
Files\boost_1_35_0), extracted there bjam and used bjam in cmd:

bjam --build-dir="D:\Program Files\boost_1_35_0" --toolset=gcc stage

I got 12 failures and 8 warnings from this (other few hundrds were ok)


I'm now trying to compile World.cpp and use it from python


World.cpp:
--------------------------
#include "boost/python.hpp"
using namespace boost::python;

BOOST_PYTHON_MODULE(hello)
{
    class_<World>("World")
        .def("greet", &World::greet)
        .def("set", &World::set)
    ;
}


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



When trying to compile it I get:
----------------------------
E:\Source>g++ World.cpp
World.cpp:1:28: boost/python.hpp: No such file or directory
World.cpp:2: error: `boost' has not been declared
World.cpp:2: error: `python' is not a namespace-name
World.cpp:2: error: expected namespace-name before ';' token
World.cpp:4: error: expected constructor, destructor, or type conversion 
before
'(' token
World.cpp:15: error: `std::string' has not been declared
World.cpp:15: error: ISO C++ forbids declaration of `msg' with no type
World.cpp:16: error: using-declaration for non-member at class scope
World.cpp:16: error: expected `;' before "greet"
World.cpp:17: error: expected `;' before "std"
World.cpp:17: error: using-declaration for non-member at class scope
World.cpp:17: error: expected `;' before "msg"
World.cpp: In member function `void World::set(int)':
World.cpp:15: error: 'struct World' has no member named 'msg'
----------------------------


What have i done wrong and what should have been done instead?

Thank you in advance. :)



More information about the Python-list mailing list