Boost logo

Boost-Build :

Subject: [Boost-build] How to link other static libraries using Boost.Build
From: au9ustine (au9ustine_at_[hidden])
Date: 2011-11-16 03:04:26


Hello,everybody! This is my first time to post a question to this
maillist. If you don't know what I've post, please forgive my poor
English.

It's recommended to use Boost.Build to compile Boost.Python extension
from official documentation, but I've no idea how to link the other
static libraries when compiling a Boost.Python extension. Althrough
I've checked the documentation of Boost.Build, the instruction of
Jamroot and its weird language are so complicated for me.

The below codes come from BOOST_ROOT/libs/python/example/tutorial
originally. I've changed them slightly so that they can satisfy my
requirements.

==== This is the Jamroot ====
import python ;

if ! [ python.configured ]
{
    ECHO "notice: no Python configured in user-config.jam" ;
    ECHO "notice: will use default configuration" ;
    using python ;
}

# Specify the path to the Boost project. If you move this project,
# adjust this path to refer to the Boost root directory.
use-project boost
  : ../../../.. ;

# Set up the project-wide requirements that everything uses the
# boost_python library from the project whose global ID is
# /boost/python.
project
  : requirements <library>/boost/python//boost_python ;
project
  : requirements <include>D:/Program\ Files/CGAL-3.9/include ;
project
  : requirements <include>D:/Program\ Files/CGAL-3.9/auxiliary/gmp/include ;

# Declare the three extension modules. You can specify multiple
# source files after the colon separated by spaces.
python-extension hello_ext : hello.cpp ;

# Put the extension and Boost.Python DLL in the current directory, so
# that running script by hand works.
install convenient_copy
  : hello_ext
  : <install-dependencies>on <install-type>SHARED_LIB <install-type>PYTHON_EXTENSION
    <location>.
  ;

# A little "rule" (function) to clean up the syntax of declaring tests
# of these extension modules.
local rule run-test ( test-name : sources + )
{
    import testing ;
    testing.make-test run-pyd : $(sources) : : $(test-name) ;
}

# Declare test targets
run-test hello : hello_ext hello.py ;

==== This is the hello.cpp ====
#include <boost/python/module.hpp>
#include <boost/python/def.hpp>
#include <boost/geometry.hpp>
#include <boost/geometry/geometries/point_xy.hpp>
#include <boost/geometry/geometries/polygon.hpp>
#include <CGAL/Exact_predicates_inexact_constructions_kernel.h>
#include <CGAL/convex_hull_2.h>

char const* greet()
{
   return "hello, world";
}

double d(){
  using namespace boost::geometry;
  model::d2::point_xy<int> p1(1,1), p2(2,2);
  return distance(p1,p2);
}

size_t cgal_d(){
  typedef CGAL::Exact_predicates_inexact_constructions_kernel K;
  typedef K::Point_2 Point_2;
  typedef std::vector<Point_2> Points;
  Points points, result;
  points.push_back(Point_2(0,0));
  points.push_back(Point_2(10,0));
  points.push_back(Point_2(10,10));
  points.push_back(Point_2(6,5));
  points.push_back(Point_2(4,1));
  CGAL::convex_hull_2( points.begin(), points.end(), std::back_inserter(result) );
  return result.size();
}

BOOST_PYTHON_MODULE(hello_ext)
{
    using namespace boost::python;
    def("greet", greet);
    def("d", d);
    def("cgal_d", cgal_d);
}

==== And this is my user-config.jam ====
using msvc : 9.0 ;

using python : 2.7 : D:/Python27 ;

==== But finally I got ====
E:\090208107\src\projects\boost_1_47_0\libs\python\example\tutorial>%BOOST_ROOT%
\bjam
...patience...
...patience...
...patience...
...found 3472 targets...
...updating 6 targets...
msvc.link.dll bin\msvc-9.0\debug\threading-multi\hello_ext.pyd
LINK : fatal error LNK1104: cannot open file 'CGAL-vc90-mt-gd.lib'

        call "C:\Program Files\Microsoft Visual Studio 9.0\VC\bin\vcvars32.bat"
>nul
link /NOLOGO /INCREMENTAL:NO /DLL /DEBUG /MACHINE:X86 /subsystem:console /out:"b
in\msvc-9.0\debug\threading-multi\hello_ext.pyd" /IMPLIB:"bin\msvc-9.0\debug\thr
eading-multi\hello_ext.lib" /LIBPATH:"D:\Python27\libs" @"bin\msvc-9.0\debug\t
hreading-multi\hello_ext.pyd.rsp"
        if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%

...failed msvc.link.dll bin\msvc-9.0\debug\threading-multi\hello_ext.pyd bin\msv
c-9.0\debug\threading-multi\hello_ext.lib bin\msvc-9.0\debug\threading-multi\hel
lo_ext.pdb bin\msvc-9.0\debug\threading-multi\hello_ext.pdb...
...skipped <p.>hello_ext.pyd for lack of <pbin\msvc-9.0\debug\threading-multi>he
llo_ext.pyd...
...skipped <pbin\hello.test\msvc-9.0\debug\threading-multi>hello for lack of <pb
in\msvc-9.0\debug\threading-multi>hello_ext.pyd...
...failed updating 3 targets...
...skipped 3 targets...

E:\090208107\src\projects\boost_1_47_0\libs\python\example\tutorial>

If there is someone who can help me and/or provide some simple codes
snippet that can show how to use Boost.Build, I'm quite appriciated
that.

Thank you very much.


Boost-Build list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk