1
votes

I've been trying to get to level 0 of using Boost-Python (on Windows 10 with VS2015 and Python 3.6 installed) namely building the tutorial, for basically the last full 3 days,. I first tried to go through the official tutorial:- http://www.boost.org/doc/libs/1_64_0/libs/python/doc/html/tutorial/tutorial/hello.html but it won't work. Seems to me the example is setup such that it needs the 'Jamfile' in the 'tutorial' directory and the 'Jamroot' in parent directory.

After investigation/search, I started the answer in:- Can't run bjam to compile boost python tutorial Currently I am stuck with

fatal error C1083: Cannot open include file: 'boost/python/module.hpp': No such file or directory

I'll keep trying, but First question:-

1) Seems to me I should be able to build using bjam.exe with the following files in boost_1_64_0\libs\python\tutorial : hello.cpp, hello.py, some .lib (like boost_python3-vc140-mt-gd-1_64.lib or something), a suitable Jamfile, bjam.exe in the tutorial directory and a suitable Jamroot in the parent directory and user-config.jam in my HOMEPATH. Is that right ?

In fact, after much thinking and trying things out last week, I got a notch further, getting the following linker error :-

LINK : fatal error LNK1207: incompatible PDB format in 'C:\Program Files\boost\boost_1_64_0\libs\python\example\tutorial\hello_ext.pdb'; delete and rebuild call "C:\Users\DIAMON~1\AppData\Local\Temp\b2_msvc_14.0_vcvarsall_x86.cmd" nul link /NOLOGO /INCREMENTAL:NO /DLL /NOENTRY /DEBUG /MACHINE:X86 /MANIFEST /subsystem:console /out:"hello_ext.dll" /IMPLIB:"hello_ext.pdb" /LIBPATH:"C:\Users\DiamondExp\AppData\Local\Programs\Python\Python36-32\libs" @"hello_ext.dll.rsp"

if %ERRORLEVEL% NEQ 0 EXIT %ERRORLEVEL%

...failed msvc.link.dll hello_ext.dll hello_ext.pdb hello_ext.pdb...

and then I lost - I have to very shamefully admit - the partially working Jamfile/Jamroot when I stupidly deleted my whole boost directory to start from a "clean state". was really dumb. I couldn't really find anywhere to go from this fatal error LNK1207 anyway.

I'm very eager to get into this Boost-Python stuff, would make my life a lot easier. So I would be so grateful for any input from an experienced Boost-Python and/or Boost.Build user and maybe to get any amount of the following specific questions answered :

2) How should I modify my 'libs\python\example\Jamroot' (specifically after the "< location>") and 'libs\python\example\tutorial\Jamfile' ? Current state reproduced below. What would be a so-called "default location" for Boost.Python ?

3) Is it a good alternative to ditch bjam.exe and try and build with VisualStudio 2015 directly ? Like there: Building/including Boost.Python in VS2013

4) It seems from a few posts that something happened after Boost 1_55. Several people could not get it to work. Any known compatibilty problem between Boost-Python and msvc14.0 or Python 3.x ? For instance : Compile boost-python tutorial with VS-2015 CTP 5 and Python 3.5a on Windows 10 TP

5) I'm confused about the 32bit/64bit thing. I have 64-bit OS (Windows10) and Python 32bit installed. What should I match my 'address-model option' in the invokation of b2.exe to ? does it matter at all ?

6) is it worth using a .dll rather than a .lib here ?

Hope somebody makes it that far...

Jamfile : (nothing modified from default)

import python ;

project tutorial
  : requirements
    <location>.
    ;

python-extension hello_ext : hello.cpp ;

run-test hello : hello_ext hello.py ;

alias test : hello ;
explicit test ;

Jamroot :

import python ;

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

# Adjust the following if Boost.Python isn't installed in a default location
lib boost_python ;

project
  : requirements
    <include>C:\\Users\\DiamondExp\\Downloads\\boost_1_64_0\\boost_1_64_0\\boost\\python
    <library>boost_python
;

rule run-test ( test-name : sources + )
{
  import testing ;
  testing.make-test run-pyd : $(sources) : : $(test-name) ;
}

#build-project quickstart ;
build-project tutorial ;
if [ python.numpy ]
{
  build-project numpy ;
}

user-config.jam

# -------------------
# MSVC configuration.
# -------------------

# Configure specific msvc version (searched for in standard locations and PATH).
using msvc : 14.0 : "C:\\Program Files (x86)\\Microsoft Visual Studio 14.0\\VC\\bin\\cl.exe" ;


# ---------------------
# Python configuration.
# ---------------------

# Configure specific Python version.
# using python : 3.6 : /usr/bin/python3 : /usr/include/python3.1 : /usr/lib ;

using python 
    : 3.6                   # Version
    : C:\\Users\\DiamondExp\\AppData\\Local\\Programs\\Python\\Python36-32\\python.exe      # Python Path
    : C:\\Users\\DiamondExp\\AppData\\Local\\Programs\\Python\\Python36-32\\include         # include path
    : C:\\Users\\DiamondExp\\AppData\\Local\\Programs\\Python\\Python36-32\\libs            # lib path(s)
    : <define>BOOST_ALL_NO_LIB=1
    ;
1
IMHO, if you don't already use BJam for something else, don't bother with it. It's just a matter of setting few paths and linking with the right libs, so use whatever approach you're familiar with.Dan Mašek
To add to @DanMašek comment, recently Boost Steering Committee announced the desire and intent to move Boost build system to CMake - see this. Another reason to not bother with bjam unless for whatever reason you have to.doqtor
OK. thanks for the advice. I'll try VS directly then. Hopefully it'll get me somewhere.Joooss
Your first "I'm stuck" is due to the wrong path in your jamroot. You need to specify the root: "C:\\Users\\DiamondExp\\Downloads\\boost_1_64_0\\boost_1_64_0" in your caseArnout

1 Answers

2
votes

If you are interested in C++ to Python, you should take a look at Pybind11. It is a header-only library based on Boost and that focus on binding C++ to Python.

You can download all resources here.

This is the option I chose when I realised that setting up the Boost python library was quite hazardous on Windows.