By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
444,199 Members | 1,125 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 444,199 IT Pros & Developers. It's quick & easy.

boost

P: n/a
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. :)
Jun 27 '08 #1
Share this Question
Share on Google+
2 Replies


P: n/a
deepest1 wrote:
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

--
Sator Laser GmbH
Geschäftsführer: Thorsten Föcking, Amtsgericht Hamburg HR B62 932

Jun 27 '08 #2

P: n/a
Thanks for help.

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

:)
Jun 27 '08 #3

This discussion thread is closed

Replies have been disabled for this discussion.