Boost logo

Boost Users :

Subject: [Boost-users] boost python beginner questions...
From: Jebagnana Das (jebagnanadas_at_[hidden])
Date: 2009-11-20 06:28:41


Hello to all,
                 Thank you for giving me an oppurtunity to interact with you
all through this mailing list..

                After installing boost python and bjam from ubuntu 9.04
repositories i can't find a clear detailed description about compiling and
running the boost python program from it's tutorials .. Can any among you
please tell me what are the options we need to be give to compile like
g++ filename path/to/boost etc.,
and run this hello world boost python program
http://wiki.python.org/moin/boost.python/SimpleExample using and without
bjam.

               This is what i did. I created a c++ file named hello.cpp with
the contents..

#include <string>

namespace { // Avoid cluttering the global namespace.

  // A couple of simple C++ functions that we want to expose to Python.
  std::string greet() { return "hello, world"; }
  int square(int number) { return number * number; }
}
#include <boost/python.hpp>
using namespace boost::python;

BOOST_PYTHON_MODULE(getting_started1)
{
    // Add regular functions to the module.
    def("greet", greet);
    def("square", square);
}

         What should i do to make this as "a shared library and put it on
the PYTHONPATH" as said in the tutorial?? (This question may sound trivial
or silly but these are essential components that "must must" be included
while writing a tutorial bcoz. it's gonna be read by people at all levels..
This 'll dampen the spirits of the beginner if he can't get to know how to
compile and run it.. Sorry if i offended you..).
FYI:I'm using python 3.1

Thanks & Regards..



Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net