Skip to content

Building with VS2017 fails #1424

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
joa-quim opened this issue Jan 19, 2018 · 19 comments
Closed

Building with VS2017 fails #1424

joa-quim opened this issue Jan 19, 2018 · 19 comments

Comments

@joa-quim
Copy link

First error was that it insisted in requiring gfortran so I tricked it my making a symlink with flang.exe.
Next error, which I could not solve is this:

(C:\programs\Miniconda3) V:\openblas\build>cmake --build . --config Release
ninja: error: 'openblas.def', needed by 'lib/liblibopenblas.dll', missing and no known rule to make it

apparently openblas.def should have been generated in previous step, but it wasn't

@isuruf
Copy link
Contributor

isuruf commented Jan 20, 2018

Are you using latest master of OpenBLAS? What is the cmake generator and the options you used?

@joa-quim
Copy link
Author

Yes, 0.2.20 and I'm following the instructions of point 1 of

https://github.com/xianyi/OpenBLAS/wiki/How-to-use-OpenBLAS-in-Microsoft-Visual-Studio

@isuruf
Copy link
Contributor

isuruf commented Jan 20, 2018

You need to use openblas git version for that.

@joa-quim
Copy link
Author

Well, then perhaps change the entry sentence.

As of OpenBLAS v0.2.15, we support MinGW and Visual Studio (using CMake to generate visual studio solution files) to build OpenBLAS on Windows.

@joa-quim
Copy link
Author

Hmm, not better

-- The Fortran compiler identification is unknown
flang.exe: warning: argument unused during compilation: '-E' [-Wunused-command-line-argument]
flang.exe: error: linker command failed with exit code 1120 (use -v to see invocation)
-- Check for working Fortran compiler: C:/programs/Miniconda3/Library/bin/flang.exe
CMake Error: Error required internal CMake variable not set, cmake may not be built correctly.
Missing variable is:
CMAKE_Fortran_PREPROCESS_SOURCE
CMake Error at C:/programs/CMake/share/cmake-3.8/Modules/CMakeTestFortranCompiler.cmake:30 (try_compile):
  Failed to generate test project build system.
Call Stack (most recent call first):
  cmake/f_check.cmake:24 (enable_language)
  cmake/prebuild.cmake:84 (include)
  cmake/system.cmake:118 (include)
  CMakeLists.txt:44 (include)

@brada4
Copy link
Contributor

brada4 commented Jan 20, 2018

flang detection is only with development version

@joa-quim
Copy link
Author

This was with development version.

@martin-frbg
Copy link
Collaborator

Your version of CMAKE is too old to recognize flang - it seems that the relevant definitions were added to cmake in August as https://gitlab.kitware.com/cmake/cmake/commit/2f3a07a9 so you would need at least CMAKE 3.10.0

@isuruf
Copy link
Contributor

isuruf commented Jan 20, 2018

Actually for recognizing flang on windows, you need the development version of cmake. (Or use the cmake from conda)

@joa-quim
Copy link
Author

Thanks, updated cmake and advanced quite a bit ... but it stops with hundreds of errors like

flang.exe: error: no such file or directory: 'CMakeFileslibopenblas.dirlapack-netlibLAPACKEutilslapacke_z_nancheck.c.obj'
flang.exe: error: no such file or directory: 'CMakeFileslibopenblas.dirlapack-netlibLAPACKEutilslapacke_ztr_trans.c.obj'
flang.exe: error: no input files
ninja: build stopped: subcommand failed.

A missing slash separator apparently because, for example, the lapacke_ztr_trans.c.obj file exists in

V:\openblas\build\CMakeFiles\libopenblas.dir\lapack-netlib\LAPACKE\utils

@joa-quim
Copy link
Author

One more try. I hand edited the build.ninja file and changed all \ by / and the above errors went way, but now

[2/3] Linking Fortran shared library lib/libopenblas.dll
FAILED: lib/libopenblas.dll lib/libopenblas.lib
cmd.exe /C "cd . && C:\programs\Miniconda3\Library\bin\flang.exe  -Wall  /machine:x64 /debug /INCREMENTAL /DEF:V:/openblas/build/openblas.def  /DEF:openblas.def -shared  -o lib/libopenblas.dll @CMakeFiles/libopenblas.rsp  && cd ."
flang.exe: error: no such file or directory: '/machine:x64'
flang.exe: error: no such file or directory: '/debug'
flang.exe: error: no such file or directory: '/INCREMENTAL'
flang.exe: error: no such file or directory: '/DEF:V:/openblas/build/openblas.def'
flang.exe: error: no such file or directory: '/DEF:openblas.def'
ninja: build stopped: subcommand failed.

@isuruf
Copy link
Contributor

isuruf commented Jan 20, 2018

Did you clean the build directory after changing cmake version?

@joa-quim
Copy link
Author

No, I hadn't but it makes no difference. Same errors.

@joa-quim
Copy link
Author

joa-quim commented Jan 20, 2018

Sorry, cleaned the build dir of another project. Redoing it now.

@joa-quim
Copy link
Author

but again, no difference. Still errors.

@vakonovalov
Copy link

vakonovalov commented Mar 28, 2018

I was able to build OpenBLAS (recent commit c7b55b6 from develop branch) on Windows. I used VS2015, i don't know if it would work with VS2017.
The problem with CMAKE_Fortran_PREPROCESS_SOURCE is indeed solved by installing a new version of CMake. I used 3.10.2.

Then, however, there were errors with linking:

[2/3] Linking Fortran shared library lib\openblas.dll
FAILED: lib/openblas.dll lib/Release/openblas.lib
cmd.exe /C "cd . && <PATH_TO_CONDA>\Library\bin\flang.exe    /machine:x64 /INCREMENTAL:NO /DEBUG /OPT:REF /OPT:ICF /DEF:<PATH_TO_OPENBLAS>\OpenBLAS-develop\build\openblas.def  /DEF:openblas.def -shared  -o lib\openblas.dll @CMakeFiles/openblas.rsp  && cd ."
ninja: build stopped: subcommand failed.

Using build.ninja i determined that Fortran_SHARED_LIBRARY_LINKER__openblas is responsible for incorrect formation of this command.
In rules.ninja i changed

rule Fortran_SHARED_LIBRARY_LINKER__openblas
  command = cmd.exe /C "$PRE_LINK && <PATH_TO_CONDA>\Library\bin\flang.exe  $LANGUAGE_COMPILE_FLAGS $ARCH_FLAGS $LINK_FLAGS -shared $SONAME_FLAG$SONAME -o $TARGET_FILE @$RSP_FILE  && $POST_BUILD"

to

rule Fortran_SHARED_LIBRARY_LINKER__openblas
  command = cmd.exe /C "$PRE_LINK && link  $LANGUAGE_COMPILE_FLAGS $ARCH_FLAGS $LINK_FLAGS /DLL /OUT:$TARGET_FILE @$RSP_FILE  && $POST_BUILD"

But that was not all. There was another small bug:

[3/3] Linking C executable utest\openblas_utest.exe
FAILED: utest/openblas_utest.exe
.....
LINK : fatal error LNK1181: cannot open input file "lib\Release\openblas.lib"
ninja: build stopped: subcommand failed.

This problem was solved by manually copying openblas.lib from lib to lib\Release
After these fixes, the build was finally completed.

@isuruf
Copy link
Contributor

isuruf commented Mar 29, 2018

@vakonovalov, can you remove your changes and try with cmake-3.11.0 and see if it succeeds or not?

@vakonovalov
Copy link

I tried to build OpenBLAS using CMake 3.11.0. The build was successful, there was no need for my intervention in the process.

I noticed that the rule Fortran_SHARED_LIBRARY_LINKER__openblas have changed to

rule Fortran_SHARED_LIBRARY_LINKER__openblas
  command = cmd.exe /C "$PRE_LINK && D:\Programs\CMake\bin\cmake.exe -E vs_link_dll --intdir=$OBJECT_DIR --manifests $MANIFESTS -- D:\Programs\MICROS~1.0\VC\bin\amd64\link.exe /nologo @$RSP_FILE  /out:$TARGET_FILE /implib:$TARGET_IMPLIB /pdb:$TARGET_PDB /dll /version:0.3 $LINK_FLAGS   && $POST_BUILD"

Now it works correctly. Also, there was no need to manually copy openblas.lib from lib to lib\Release.

So, with CMake 3.11.0 it seems that everything works fine.

@martin-frbg
Copy link
Collaborator

According to #1521, building with VS2017 should work as well with current conda/cmake/ninja/flang

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants