compile some code with boost.python by mingw in win7-64bit

后端 未结 2 1353
迷失自我
迷失自我 2021-01-03 13:01

I decided to make my program compatible with windows environment.But I have very little programming experience on windows.There are some errors need help.

Environmen

2条回答
  •  栀梦
    栀梦 (楼主)
    2021-01-03 13:31

    To make the tutorial run on Boost 1_60_0, on Windows 7, with a 64 bit mingw gcc (version 4.8.1), I needed to use the commands in an msys shell:

    rm -rf bin.v2/libs/python stage/lib/libboost_python-mgw48-*
    ./b2.exe toolset=gcc define=MS_WIN64 --with-python link=static
    

    to make the boost python library. This command shall be executed in the Boost root directory. Note that without the define=MS_WIN64 I get undefined errors on __imp_py_InitModule4 as indicated in Python extensions for Win64 via GCC.

    After that, it is straightforward to compile the Python boost tutorial:

    g++ hello.cpp -I /c/projects/boost_1_60_0/ -I /c/prog64/Python27/include -DBOOST_PYTHON_STATIC_LIB  /c/projects/boost_1_60_0/stage/lib/libboost_python-mgw48-mt-1_60.a /c/prog64/Python27/python27.dll -DMS_WIN64 -shared -o hello_ext.pyd
    

    This also worked for Boost 1_54_0

提交回复
热议问题