boost

D

deepest1

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. :)
 
U

Ulrich Eckhardt

deepest1 said:
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)

Hmm, I remember trying to use Boost 1.35 with Python 2.5 on my Debian system
and also having problems, are you sure that at least the Python helper libs
are correctly compiled?
E:\Source>g++ World.cpp
World.cpp:1:28: boost/python.hpp: No such file or directory

Try -I "D:\Program Files\boost_1_35_0" as additional argument. Further, you
will need to tell g++ to link with the according boost library
(-lboost_python or something like that) and where it can find that lib
(-L"D:\Program Files\boost_1_35_0\stage").

Uli
 
D

deepest1

Thanks for help.

I lost more then 10 hours on boost today, but it finally works, and I'm
pleased with it.

:)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,066
Latest member
VytoKetoReviews

Latest Threads

Top