Closed ilayn closed 5 years ago
Up to and including that point, it should be pure GCC toolchain, there's no MSVC involved yet. Maybe the libopenblas.a (where did you get it from?) you have comes from incompatible mingw version, than what you are building scipy with?
Looking over our CI, I think mingw 6.3.0 or 6.4.0 may be a better match for providing the runtime libs needed by OpenBLAS (libquadmath & so on), but as Pauli says would be useful to know where you are getting that OpenBLAS..
I directly downloaded the precompiled binaries for windows from the sourceforge repository version 0.3.7 and setup a site.cfg accordingly for numpy. Same didn't go through for SciPy.
The openblas SF package contains a prebuilt MSVC .lib
library, so numpy probably didn't use mingw at all. gfortran however needs to use the .a
library, which presumably was built with a mingw version incompatible with what you have.
See also https://scipy.github.io/devdocs/building/windows.html
Indeed, I was trying to fix those instructions since I was one of the authors back then. But currently it is completely out of date and getting some traffic.
OK brought down to a single instance of the error given above so I think I can provide more information since I'm a bit more aware of the tools I'm using.
What I have been doing is the following for building the OpenBLAS
make BINARY=64 CC=gcc FC=gfortran
The details of compilers are
and for gfortran
When the build is finished I also use make install PREFIX=/c/opt
to get the artifacts
After that I turn to a regular windows command prompt and then first add a site.cfg
echo "[lapack_src]
>> libraries = openblas
>> library_dirs = C:\opt\lib
>> include_dirs = C:\opt\include
>> runtime_library_dirs = C:\opt\lib" > site.cfg
This time python setup.py build
fails with not being able to find the openblas libs
So back to our previous instructions (deleting the site.cfg
file and placing/renaming the .a file in the ../../programs/libs/openblas.a
folder). Now from the build logs I can see that linalg.lapack module and other fortran parts are compiled and comes down to the scipy.cluster
and exits with the following
creating build\temp.win-amd64-3.6\Release\scipy
creating build\temp.win-amd64-3.6\Release\scipy\cluster
C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\bin\HostX86\x64\cl.exe /c /nologo /Ox /W3 /GL /DNDEBUG /MT -DHAVE_CBLAS -IC:\Users\Ilhan Polat\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy-1.18.0.dev0+77b421d-py3.6-win-amd64.egg\numpy\core\include -IC:\Users\Ilhan Polat\AppData\Local\Programs\Python\Python36\lib\site-packages\numpy-1.18.0.dev0+77b421d-py3.6-win-amd64.egg\numpy\core\include -IC:\Users\Ilhan Polat\AppData\Local\Programs\Python\Python36\include -IC:\Users\Ilhan Polat\AppData\Local\Programs\Python\Python36\include -IC:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.22.27905\include -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\ucrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\shared -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\um -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\winrt -IC:\Program Files (x86)\Windows Kits\10\include\10.0.18362.0\cppwinrt /Tcscipy\cluster\_vq.c /Fobuild\temp.win-amd64-3.6\Release\scipy\cluster\_vq.obj
could not find library 'openblas' in directories ['C:\\Users\\Ilhan Polat\\Documents\\GitHub\\scipy\\build\\openblas']
C:\Program Files\mingw-w64\x86_64-7.1.0-posix-seh-rt_v5-rev2\mingw64\bin\gfortran.exe -Wall -g -Wall -g -shared -Wl,--whole-archive ..\..\..\AppData\Local\Programs\Python\Python36\lib\openblas.a -Wl,--no-whole-archive -LC:\Program Files\mingw-w64\x86_64-7.1.0-posix-seh-rt_v5-rev2\mingw64\lib\gcc\x86_64-w64-mingw32\7.1.0 -LC:\Users\Ilhan Polat\AppData\Local\Programs\Python\Python36\libs -LC:\Users\Ilhan Polat\AppData\Local\Programs\Python\Python36\PCbuild\amd64 -Lbuild\temp.win-amd64-3.6 -o build\temp.win-amd64-3.6\Release\.libs\libopenblas.5QHOTOUO4U4ER4LE7BFKCC7L4PACMGUD.gfortran-win_amd64.dll -Wl,--allow-multiple-definition -Wl,--output-def,build\temp.win-amd64-3.6\Release\libopenblas.5QHOTOUO4U4ER4LE7BFKCC7L4PACMGUD.gfortran-win_amd64.def -Wl,--export-all-symbols -Wl,--enable-auto-import -static -mlong-double-64
..\..\..\AppData\Local\Programs\Python\Python36\lib\openblas.a(cblas_xerbla.obj):xerbla.c:(.text+0xc): undefined reference to `__imp___acrt_iob_func'
..\..\..\AppData\Local\Programs\Python\Python36\lib\openblas.a(openblas_error_handle.obj):openblas_error_handle.c:(.text+0x27): undefined reference to `__imp___acrt_iob_func'
collect2.exe: error: ld returned 1 exit status
error: Command "C:\Program Files\mingw-w64\x86_64-7.1.0-posix-seh-rt_v5-rev2\mingw64\bin\gfortran.exe -Wall -g -Wall -g -shared -Wl,--whole-archive ..\..\..\AppData\Local\Programs\Python\Python36\lib\openblas.a -Wl,--no-whole-archive -LC:\Program Files\mingw-w64\x86_64-7.1.0-posix-seh-rt_v5-rev2\mingw64\lib\gcc\x86_64-w64-mingw32\7.1.0 -LC:\Users\Ilhan Polat\AppData\Local\Programs\Python\Python36\libs -LC:\Users\Ilhan Polat\AppData\Local\Programs\Python\Python36\PCbuild\amd64 -Lbuild\temp.win-amd64-3.6 -o build\temp.win-amd64-3.6\Release\.libs\libopenblas.5QHOTOUO4U4ER4LE7BFKCC7L4PACMGUD.gfortran-win_amd64.dll -Wl,--allow-multiple-definition -Wl,--output-def,build\temp.win-amd64-3.6\Release\libopenblas.5QHOTOUO4U4ER4LE7BFKCC7L4PACMGUD.gfortran-win_amd64.def -Wl,--export-all-symbols -Wl,--enable-auto-import -static -mlong-double-64" failed with exit status 1
Any pointers would be appreciated.
This bit from a SO answer looks relevant too
I would suggest to try to build an openblas.a that can be successfully built to a DLL, using the command the build in the end fails with.
Note especially that it's trying to use gfortran from C:\Program Files\mingw-w64\x86_64-7.1.0-posix-seh-rt_v5-rev2\mingw64\bin\gfortran.exe
whereas you appear to have built openblas with a different version of gcc/gfortran (9.2.0). Try using just one version of mingw, to avoid the runtime mismatch problems I mentioned earlier.
Anyway good luck. To my understanding the windows build instructions using msys2 and msvc on the web page should still be applicable. Indeed, the scipy-wheels repository is successfully building wheels every week on appveyor with a similar setup.
I think you are right those 7.1.0 items are probably from an early installation ended up on the PATH env var.
To my understanding the windows build instructions using msys2 and msvc on the web page should still be applicable. Indeed, the scipy-wheels repository is successfully building wheels every week on appveyor with a similar setup.
Yes should be but the repo is retired (#9669) so I'm trying to make an overhaul directly building from sources without so much extras.
I see, you mean the discussion about the openblas build is out of date. I haven't checked that part.
Indeed, and straight from the Sourceforge libs didn't end up well so I was trying to build-your-own-openblas path.
Thanks @pv for noticing that version detail. It was indeed the culprit. The build was choosing mingw64 compilers instead of the msys2 ones which have been used to build the openblas lib.
The fix is to make sure that the compilers used to build OpenBLAS has highest priority in the PATH environment variables.
I can finally start working on that Windows build instructions page.
@ilayn that would be great.
Note @timmclennan and I spent most of the SciPy Conference sprint trying to build on Windows but didn't get it working.
That's part of the reason for the updates to the Linux Quickstart (to mention the possibility of using WSL or EC2 instances from a Windows machine) and the new Docker Quickstart (which work on Windows). Still, a native Windows Quickstart would be very helpful. If you are going to write something, please consider starting from one of the Quickstarts and adding it to the newer Development Environment section of the contributor guide rather than revising the older Building from sources section. Sure, we might move the Quickstarts to their own page like the Building instructions, but once we have a replacement for each of the Building instructions I'd like to remove all that material as it's somewhat outdated.
Actually, if you get it working, maybe we can set up a Windows-based Docker container so it is very repeatable. I really like to be able to build for Windows in a container, then I could do most of my work outside of it.
Yes I think I've brought it to a base minimum set of instructions and made it working, quickly wrapping the ?geequ
and ?geepub
as we speak.
Do you want to get rid of the Building from sources section eventually?
Yes
OK. Let me try to cheat from the recent docker efforts. Fingers crossed 😃
Yeah I managed to get scipy building using MSVC 2015 and the Intel Fortran compiler. It isn't actually too hard if you effectively follow the conda feedstock recipe. The biggest issues I ran into were a couple of tests hanging.
After the conference I focused on figure out what the issue was with the tests. It turns out that these particular tests all rely on the multiprocessing.Pool functionality to run a multiprocess map operation, which fails under the scipy integrated test environment.
The failure seems unrelated to scipy and appears to related to running pytests that change the directory, use the multiprocess pool functionality and the windows MKL version of numpy. Under those circumstances a failure case can be found that has nothing directly to do with scipy. One final point is that the conda builds disable the relevant tests.
At some point I intended to write this up further but have been pretty slammed for work in the time since.
Although NumPy compiled succesfully (as far as I can tell) with same toolchain, it started to choke with SciPy and according to Rust community this is because certain headers are inlined apparently (see details below). Hence missing references are caused.
I am not very hopeful since it is Windows but I'd be happy if anybody can help to tame this build chain. Unfortunately, I have no understading of these issues to provide more feedback.