Cant run bjam to compile boost python tutorial

2024/9/8 10:00:16

I am trying to follow this tutorial on wrapping C++ code for python for Windows.I installed python.Downloaded the latest version of boost(1_55).First I ran bootstrap.bat to build bjam.exe.Next, I configured boost_1_55_0\tools\build\v2\user-config.jam to use msvc10 compiler and added the path to python installation. Now,based on the tutorial :

Now we are ready... Be sure to cd to libs/python/example/tutorialwhere the tutorial "hello.cpp" and the "Jamroot" is situated.

Finally:

bjam

Trying to run bjam in that directory gives me : "bjam is not recognized as internal or external command" error.What have I missed here? Should user-config.jam reside in another location?Or bjam added to system path?

UPDATE:

Ok.Thanks to @john I had to add bjam to system path.But now,running it,hello_ext.lib is created in \boost_1_55_0\libs\python\example\tutorial\bin\msvc-11.0\debug but not DLL.Based on the tutorial I should get DLL file for the extension.Now, I am not sure how python links with extension.But if I assume it does like C++ then it should have linked with hello_ext.lib.But if run :

python hello.py

which contains imported method from the extension ,the python runtime crashes.Isn't there a comprehensive tutorial on this workflow?Boost doc sucks completely on this.

Answer

This worked for me:

1.) unzip boost_1_55_0.zip

2.) Prepare to use the Boost Library Binaries

Go to the boost_1_55_0 root directory and open a command prompt and type following commands:

Bootstrap

3.) Find user-config.jam:

Type following in the command prompt:

ECHO %HOMEDRIVE%%HOMEPATH%

4.) If the user-config.jam is in your homedrive directory please change it there as followed:

ATTENTION:

The .jam language rates a “whitespace” as a separation of arguments!

# -------------------
# MSVC configuration.
# -------------------# Configure msvc (default version, searched for in standard locations and PATH).
# using msvc ;# Configure specific msvc version (searched for in standard locations and PATH).
using msvc : 10.0 : C:\\app\\tools\\MSVisualStudio2010\\VC\\bin\\cl.exe ;….# ---------------------
# Python configuration.
# ---------------------# Configure specific Python version.
# using python : 3.1 : /usr/bin/python3 : /usr/include/python3.1 : /usr/lib ;using python : 2.5                   # Version: C:\\app\\tools\\Python25\\python.exe      # Python Path: C:\\app\\tools\\Python25\\include         # include path: C:\\app\\tools\\Python25\\libs            # lib path(s): <define>BOOST_ALL_NO_LIB=1;

5.) Build the Libraries AFTER configuration!!

Go to the boost_1_55_0 root directory and open a command prompt and type following commands:

.\b2

6.) Copy the user-config.jam to \boost_1_55_0\libs\python\example\tutorial 7.) Go further to \boost_1_55_0\stage\lib\

Rename libboost_python-vc100-mt-gd-1_55.lib to boost_python-vc100-mt-gd-1_55.lib and copy it to

\boost_1_55_0\libs\python\example\tutorial

8.) Now you should have all of these files in the \boost_1_55_0\libs\python\example\tutorial directory

hello.cpp
hello.py
user-config.jam
Jamroot
boost_python-vc100-mt-gd-1_55.lib
bjam.exe

9.) Open a command prompt in \boost_1_55_0\libs\python\example\tutorial

And type following command:

bjam

10.) After successful building..

You should have this file in the directory:

hello_ext.dll

rename this file to:

hello_ext.pyd
https://en.xdnf.cn/q/73402.html

Related Q&A

How to use np.empty inside numba compiled function; Error message All templates rejected

I ran into this weird error when trying to use np.empty in a function definition compiled with numba, and turning on nopython=True to make sure optimized typing is in effect. Its weird because numba cl…

Python ValueError: Invalid header name b:authority

I see the : is error, but I cant find a way to solve it. ValueError: Invalid header name b:authorityIts the error:File "tmall.py", line 23, in get_url response = sessions.get(url=url,headers…

Psycopg2 callproc and sql parameters

I got some SQL functionCREATE OR REPLACE FUNCTION tools.update_company(IN company_id integer, OUT value integer)RETURNS integer AS$BODY$BEGIN select * into value from function_making_int(company_id) E…

How to write Huffman coding to a file using Python?

I created a Python script to compress text by using the Huffman algorithm. Say I have the following string:string = The quick brown fox jumps over the lazy dogRunning my algorithm returns the following…

How to know if a Python multiprocessing.Lock is released or not?

>>> l = Lock() >>> l.acquire() True >>> l.release() >>> l.release() Traceback (most recent call last):File "<stdin>", line 1, in <module> Value…

How do you ensure a Celery chord callback gets called with failed subtasks?

I am using a Chord in Celery to have a callback that gets called when a Group of parallel tasks finish executing. Specifically, I have a group of functions that wrap calls to an external API. I want to…

Unpacking nested C structs in Python

I am trying to unpack a C struct that is handed to my Python program in binary form and includes another nested struct. The relevant part of the C header looks like this:typedef struct {uint8_t seq;uin…

Remove black borders on images with watermarks in Python

I have a bunch of image I would like to uniformise by removing black borders. Usually I use the Trim function of Imagemagick with the fuzz parameters but in the case the image have some watermark the r…

scipy cdist with sparse matrices

I need to calculate the distances between two sets of vectors, source_matrix and target_matrix.I have the following line, when both source_matrix and target_matrix are of type scipy.sparse.csr.csr_matr…

NumPy arrays with SQLite

The most common SQLite interface Ive seen in Python is sqlite3, but is there anything that works well with NumPy arrays or recarrays? By that I mean one that recognizes data types and does not requir…