0

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

avariant
  • 2,234
  • 5
  • 25
  • 33

2 Answers2

0

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.

Constantin Chirila
  • 1,979
  • 2
  • 19
  • 33
Ke Fan
  • 1
0

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.

Jared Forth
  • 1,577
  • 6
  • 17
  • 32
tonychang
  • 11
  • 1
  • 2