Skip to main content
gamedev.net
🔒 Locked

boost python beginner questions...

Started by pythonbeginner Nov 20, 2009 at 6:02 AM 0 replies 900+ views
Original Post
pythonbeginner
pythonbeginner
Hello to all, Thank you for giving me an oppurtunity to interact with you all through this forum.. 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 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 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..). Please explain me in detail.. FYI:I'm using python 3.1 Thanks & Regards..
the_edd
the_edd
Quote:
Original post by pythonbeginner
What should i do to make this as "a shared library and put it on the PYTHONPATH" as said in the tutorial??

Building a shared library is somewhat platform specific. On Windows it means creating a DLL, for example. On Linux, I guess it means building a .so file.

The PYTHONPATH stuff means that your Python interpreter needs to know where to look for modules. The easiest way is to add something like the following to the top of your python script:

import syssys.path.append(path_to_directory_containing_your_shared_library)


EDIT: the 2nd page of the Boost.Python tutorial tells you how to build a suitable shared library with bjam. Did you look at that?

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.