Compiling under Linux boost.python Simple method

Time:2020-7-28

Recent projects use C + + operationsPythonScript, select boost.python Library. Linux does not compile smoothly, but does not find the file under the header. The Linux version is rhel5.7. Later, I asked my colleague that it was the colleague who deleted the original system’s own Python 2.4, and then manually compiled and installed Python 3.3.

Change to another machine, Download boost again, and use the following command to compile successfully


./bootstrap.sh --with-python=/usr/bin/python 
./bjam --build-type=minimal --with-python variant=release link=static threading=multi address-model=64 --debug-configurations install 

Note: when generating the bjam tool, add the with Python parameter and specify the path of the python executable program. For specific parameters, run. / bootstrap — help

The library compiled in this way is linked to the library generated by Python 2.4. As for why the 3.3 installed by ourselves was not compiled successfully, the reason remains to be found,

Why is no best alternative for / Python_ for_ Extensions error.

——————————————————————————————–

2014 / 5 / 5 19:15 supplement:

For a custom version, compile using the following command


./b2 --with-python include="/usr/local/python3.3.5/include/python3.3m/"

Specify the python include path of the custom version through the include parameter. The above command will also report no best alternative for / python_ for_ Extensions are estimated to be caused by multiple versions of Python.

It is said that B2 is the second version of bjam. Do not use bjam in the future

In addition, it is better to compile dynamic libraries when compiling Python yourself


./configure --prefix=/usr/local/python3.3.5 --enable-shared  
make && make install  

Remember that Linux does not delete the python that comes with the system. After deleting rhel5.7, yum is not easy to use, which is very tragic

The above article is compiled under Linux boost.python The simple way is to make up all the content shared with you. I hope I can give you a reference, and I hope you can support developeppaer more.