Python 3.7 + Visual Studio 2107 + boost 1.69

余生长醉 提交于 2020-11-29 23:51:22

问题


I am trying to get boost 1.69 working with visual studio 2107. My goal is to use Numpy in C++

When I include #include boost/python/numpy.hpp

The error I am getting is:

Searching C:\boost_1_69_0\stage\lib\boost_python37-vc141-mt-gd-x32-1_69.lib:
1>LINK : fatal error LNK1104: cannot open file 'boost_numpy37-vc141-mt-gd-x32-1_69.lib'

I am pretty sure that I have this file in this directory. My architucture in the project is x86, 32-bit addrressing I built boost as follows:

  1. .\bbotstarp.bat
  2. .\b2 -j8 --toolset=msvc-14.1 --build-type=complete link=static runtime-link=static architecture=x86 address-model=32 stage --with-python

I added the include and link folders to the project. I do not use precompiled headers

Is there anything that I am missing?

Thanks


回答1:


I had the same problem. It seems like Boost python is not supported by python 3.7 vert well.

Using python 3.6 will solve this problem.




回答2:


I have been looking at this issue for months and finally figure out the root cause and solutions. The root cause that boost numpy is not built is because numpy is unable to be imported when ./b2 checks for numpy. As a clue from this post Using boost numpy with visual studio 2019 and python 3.8, you can append --debug-configuration to see the debugging information of boost python building process like this in my PC

notice: [python-cfg] Checking for NumPy...

notice: [python-cfg] running command 'C:/Anaconda3_Install_Root/envs/my_envs/python -c "import sys; sys.stderr = sys.stdout; import numpy; print(numpy.get_include())"'

And, the error comes from ImportError for some reason:

ImportError: DLL load failed while importing _multiarray_umath: The specified module could not be found.

After looking at this post numpy is already installed with Anaconda but I get an ImportError (DLL load failed: The specified module could not be found), I found this import process has to be under python environment such as under conda environment or PyCharm terminal (They both work in my PC) with all the required PATH to be imported. Now I can generate numpy static library with Python 3.8, VS 2019, boost v1.74, Windows 10. The command I use to build boost python is .\b2 --with-python python-debugging=off threading=multi variant=release li nk=static address-model=64 stage --debug-configuration. Hopefully, that will work in yours.



来源:https://stackoverflow.com/questions/55131550/python-3-7-visual-studio-2107-boost-1-69

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!