[C++-sig] Re: help building hello world example on Debian

Faheem Mitha faheem at email.unc.edu
Sun Apr 11 02:08:14 CEST 2004


Hi, Thanks for the quick and helpful reply. Replies follow.

On Fri, 09 Apr 2004 08:16:11 -0400, David Abrahams
<dave at boost-consulting.com> wrote:

> Faheem Mitha <faheem at email.unc.edu> writes:
>
>> Dear People,
>>
>> I have spent the last couple of hours trying to understand how to use
>> bjam so as to build the `hello world' tutorial example for
>> boost-python. I have not succeeded.
>>
>> I'm running Debian sarge. Debian seems me to want to use boost-python
>> 1.30.2
>
> What does that mean, specifically?

Never mind. I was talking nonsense.

>> , though I also have 1.31 installed. I have also installed bjam.
>>
>> The Jamfile from the hello world example appears below. How should I
>> modify this to work on my system? Alternatively, I'd be happy with a
>> regular Makefile.
>
> Take a clue from the libs/python/example subdirectory of your Boost
> installation (I suggest you use 1.31).  

I'd already downloaded the sources (patched for Debian), and looked at
this directory. OK, I'm now looking at this more carefully.

In what follows I'm going to try the obvious things and report what
happens.

1) The first thing I am doing is copying the directory example to
/tmp. I then tried

faheem /tmp/example>bjam -sTOOLS=gcc test
Unable to load Boost.Build: could not find build system.
---------------------------------------------------------
/tmp/example/boost-build.jam attempted to load the build system by
invoking

   'boost-build ../../../tools/build/v1 ;'

but we were unable to find "bootstrap.jam" in the specified directory
or in BOOST_BUILD_PATH (searching
/tmp/example/../../../tools/build/v1, /usr/share/boost-build).

Ok. This obviously wants files elsewhere in the source directory eg
(tools/build/vi). This is undesirable, as I don't want to have to
always build my extensions inside the source directory.

Looking at tools/build/vi, I see a lot of files ending with the words
jam. I have all the relevant binary Debian packages installed, and the
only place I see it is in
/usr/share/doc/libboost-doc/HTML/tools/build/v1 which includes a few
random files like python.jam, which do appear to correspond to the
files in tools/build in the boost sources. Wonder if some of these
files did not get copied by mistake.

Regardless, these files should be part of a dev package, not a doc
package if they are required for building.

What is the difference between v1 and v2? Why should I be using one as
opposed to the other?

Does this correspond to the v1 and v2 of Boost Build? Should I be
using v1? If so, why?

2) I then tried this command in the source directory.

This gave me

*******************************************************************
skipping Boost.Python library build due to missing or incorrect
configuration

couldn't find Python.h in "/usr/local/include/python2.2"

You can configure the location of your python installation by setting:
PYTHON_ROOT    - currently "/usr/local"
PYTHON_VERSION - The 2-part python Major.Minor version number (e.g.
                 "2.2", NOT "2.2.1")  - currently "2.2"

The following are automatically configured from PYTHON_ROOT if not
otherwise set:

    PYTHON_LIB_PATH       - path to Python library object; currently
                          "/usr/local/lib/python2.2/config"
    PYTHON_INCLUDES    - path to Python #include directories;
currently "/usr/local/include/python2.2"
*******************************************************************

Ok. So I need to set some environmental variables. However, I don't
want to have to set these environmental variables globally.

http://www.boost.org/tools/build/v1/build_system.htm#setting_variables
says I can set it in my Jamrules file. I have a Jamrules file in
libs/python/example which says

***************************************************************
...
# Edit this path to point at the root directory of your Boost
# installation.  Absolute paths work, too.
path-global BOOST_ROOT : ../../.. ;
project boost : $(BOOST_ROOT) ;
******************************************************************

Ok, putting

path-global PYTHON_ROOT : /usr ;
path-global PYTHON_VERSION : 2.3 ;

in the Jamrules files seems to do the trick after a long compilation,
and I get getting_started1.so  getting_started2.so in bin/example.

Suggestion. Add these lines above (or something similar) commented out
to the Jamrules, since these will frequently need to be
changed/adjusted depending on the system.

> [Joel, the tutorial example is not a very good one in general; people
> would like to be able to build extensions outside of their Boost tree.
> I think you ought to base the "building" example on the one in
> libs/python/example, and use project ids (e.g. @boost) as in that
> Jamfile]

Yes, I think it would be nice to have a tutorial where the
configuration files are as detailed as possible. Preferably
self-documenting.

>> I would prefer not to have to do extensive configuration of other
>> files, and I'd also prefer not to have to modify the jamfile if I
>> moved it to a different location in the directory hierarchy. Can these
>> preferences be satisfied?
>
> Yes; just use your boost-build file to indicate the location of the Boost
> project.  

If this refers to the files in tools/build/v1, I must again repeat
that they are not installed on my system. If this is an error on the
part of the Debian maintainer(s), I'd be happy to file a suitable bug
report. Let me know.

>> When running bjam on the script below I get the following. 
>>
>> bjam
>> Unable to load Boost.Build: could not find build system.
>> ---------------------------------------------------------
>> /home/faheem/wc/boost/example/boost-build.jam attempted to load the
>> build system by invoking
>>
>>    'boost-build ../../../tools/build/v1 ;'
>
> It's very probable from looking at the paths above that the
> boost-build.jam file in your example directory ought to say:
>
>      boost-build ../../tools/build/v1 ;
>
> ...or you can rewrite it to use an absolute path.  You only need one
> boost-build.jam file somewhere in the directory tree above all the
> places from which you'll invoke bjam, pointing at your Boost
> installation's tools/build/v1 directory; for example, you could put
> one at the root of your filesystem and never set it again (not
> recommended).
>
>> but we were unable to find "bootstrap.jam" in the specified directory
>> or in BOOST_BUILD_PATH (searching
>> /home/faheem/wc/boost/example/../../../tools/build/v1,
>> /usr/share/boost-build).
>>
>> I have tried reading the documentation but it seems very complicated
>> and I just get more confused. Some guidance would be appreciated.
>
> Please, which docs seem complicated and were confusing you?  We'd
> like to improve them.

Ok, here are some suggestions.

1) Please clarify which files correspond to the boost build system. If
these tools/build/v1 should be part of a binary installation, plese
say so. It is is not reasonable to expect people to build against a
complete copy of the boost sources.

2) Also, all this v1/v2 stuff is unclear. My impression is that v1 is
the "stable" version of the build system, and v2 is the unstable one,
but it would be useful to say something about this explicitly.

3) Make the tutorial example config files (eg. Jamfile, Jamrules,
boost-build.jam) as self-contained and as detailed as possible, so a
new user only needs to look at other documentation if he has special
needs. Basically, include all configuration variable settings that
might reasonably need to be changed, possibly commented out, and with
enough explanation that the user could figure out what he needed to
change it to,

Daniel Holth just wrote that distutils works for him on Linux
(apparently he uses Gentoo). He mentioned a Python extension package
of his called shoutpy which uses boost.python and distutils, and it
builds on Debian with no problem. Therefore, I might give this a try.

I was wondering why boost.python does not officially support
distutils. If it is for reasons of portability, I think it would do no
harm to suggest it on the web page as a possible alternative, at least
for Linux, possibly with a link to shoutpy or some other example of
use.

Sorry about the long message.
                             
                                                               Faheem.





More information about the Cplusplus-sig mailing list