0

I'm trying to clean up a legacy C-FORTRAN FLOSS code and I'm facing a rather bizarre error. There are some libraries/folders added via the add_subdirectory in the top CMakeLists.txt file. Running the cmake .. command in the build folder successfully generates the MakeFiles (except some minor warnings which might be false positive). However, when compiling with make I get a wiered error:

Scanning dependencies of target umfpack
mingw32-make[2]: Leaving directory '/path/to/elmerfem/build'
mingw32-make[2]: Entering directory '/path/to/elmerfem/build'
[ 46%] Building C object umfpack/src/umfpack/CMakeFiles/umfpack.dir/umfpack_timer.c.o
mingw32-make[2]: *** No rule to make target '/mingw64/include/cblas.h', needed by 'umfpack/src/umfpack/CMakeFiles/umfpack.dir/umfpack_tictoc.c.o'.  Stop.
mingw32-make[2]: Leaving directory '/path/to/elmerfem/build'
mingw32-make[1]: *** [CMakeFiles/Makefile2:265: umfpack/src/umfpack/CMakeFiles/umfpack.dir/all] Error 2
mingw32-make[1]: Leaving directory '/path/to/elmerfem/build'
mingw32-make: *** [Makefile:163: all] Error 2

which I don't know how to debug. In this case the /mingw64/include/cblas.h exists, and the prior CMake outputs:

-- Looking for Fortran sgemm
-- Looking for Fortran sgemm - found
-- Found BLAS: /mingw64/lib/libopenblas.dll.a
-- Looking for Fortran cheev
-- Looking for Fortran cheev - found
-- A library with LAPACK API found.
-- ------------------------------------------------
--   BLAS library:   /mingw64/lib/libopenblas.dll.a
--   LAPACK library: /mingw64/lib/libopenblas.dll.a

Show that BLAS and LAPACK have been successfully found.

I would appreciate it if you could help me know what is the problem and how I can fix it. Thanks for your kind support in advance.

The environment is:

  • MSYS2: MSYS_NT-10.0-18363
  • Windows Version 1909
  • cmake version 3.15.5
  • GNU Make 4.3
  • gcc.exe (Rev1, Built by MSYS2 project) 9.3.0

P.S.1. I just tested the code on macOS and it compiled with no problem. So it seems to be a Windows/MSYS2 specific problem.

P.S.2. I was told that I should install suitesparse library so I did

 pacman -S mingw64/mingw-w64-x86_64-suitesparse

it did not help.

P.S.3. Also following this Tweet, I should clarify that I'm using MSYS2's packages for CMake and GNU Make as explained here and here.

Foad S. Farimani
  • 12,396
  • 15
  • 78
  • 193
  • 3
    Please, do **not replace** paths and other things in the logs - copy paste error log exactly, as it is shown to you. Firstly, every thing could be important in the log. You have the weird error and ask us to find out a clue in a log.. but at the same time you have removed some clues. Second, even if you may replace only the single path -`/path/to/elmerfem`, we could *suspect* replacement of every other paths. E.g. I ask myself, "is path `/mingw64/include/cblas.h` is real or it is replaced too?". And this really makes harder to understand the log. – Tsyvarev Apr 11 '20 at 22:28
  • Dear @Tsyvarev The path I have replaced includes my private information which IMHO is irrelevant to the problem. And regarding your next question, no I have not changed the `/mingw64/include/cblas.h` path, as it is very important in this context. – Foad S. Farimani Apr 11 '20 at 22:31
  • 2
    "which IMHO is irrelevant to the problem" - E.g. paths containing a space or other special characters sometimes very relevant to the problem. Anywhere, it is better to not replace **anything** (I remember such note being in "help" articles, but now I cannot find it...). If your source or build directory contains some sensitive info then just use **other** directories for that purpose. This is really simple. Much simpler than replacing the paths in the logs and trying to not forget to replace them on every update. – Tsyvarev Apr 11 '20 at 22:41
  • @Tsyvarev you are absolutely right about the spaces and special characters. I have actually faced those error before (which I can not find the post now). But to assure you that there are no special character or such the path is `C:/Users/fsfar/Desktop/code/Elmer/elmerfem/build`. – Foad S. Farimani Apr 11 '20 at 22:44
  • 2
    "But to assure you that there are no special character or such" - Yes, there is no special characters... except it uses **native Windows** path (absolute paths starts with a driver letter with a colon after it), while the rest paths in your output use **Unix** style (absolute paths starts with a slash). I am not an expert in msys/mingw relation, but mixing paths smells a lot. Like ones in this question: https://stackoverflow.com/questions/31293526/directory-change-error-with-mingw32-make. – Tsyvarev Apr 11 '20 at 23:04
  • @Tsyvarev I can not change that, I'm afraid. I have to compile my code inside MSYS2 because there are no other viable FLOSS Fortran Compiler and the dependencies are only available as MSYS2/MinGW-w64. The alternative would be to point towards these compilers and dependencies outside the MSYS2 environment which would be even a bigger hassle AFIK. But I'm open to other possibilities. – Foad S. Farimani Apr 11 '20 at 23:07
  • 1
    Try changing your `cmake` command to `cmake -G"MSYS Makefiles" ..`. It's probably a bad idea to use `mingw32-make` instead of `make`, like your log file indicates, and that might be related to the way you are running `cmake`. – David Grayson Apr 12 '20 at 02:42
  • @DavidGrayson I tried the `cmake .. -G "MSYS Makefiles"` and got the error `CMake Error: Could not create named generator MSYS Makefiles` as you can see [here](https://i.stack.imgur.com/UJXDy.png). – Foad S. Farimani Apr 12 '20 at 08:52

1 Answers1

1

Run mingw64.exe (not msys2.exe).

Make sure to install the following packages: mingw-w64-x86_64-cmake mingw-w64-x86_64-make mingw-w64-x86_64-suitesparse and C/C++ , Fortran compilers.

Pay attention: all installed packages must be in mingw64 directory.

Change WITH_MPI value in CMakeLists.txt:

SET(WITH_MPI FALSE ...

Find paths of cmake and make with use this command: $ where cmake.exe and $ where mingw32-make.exe

for simplicity use alias command:

alias my_cmake=/d/msys64/mingw64/bin/cmake.exe
alias my_make=/d/msys64/mingw64/bin/mingw32-make.exe

Create build directory in elmer repository and then:

my_cmake -G "MinGW Makefiles" ..

my_make
sadig
  • 431
  • 1
  • 4
  • 9