我正在尝试清理legacy C-FORTRAN FLOSS code,并且遇到了一个非常奇怪的错误。通过top add_subdirectory
file中的CMakeLists.txt
添加了一些库/文件夹。在cmake ..
文件夹中运行build
命令会成功生成MakeFile
(除了some minor warnings可能为假阳性)。但是,当使用make
进行编译时,出现了一个奇怪的错误:
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
它没有帮助。
P.S.3。 在this Tweet之后,我还应阐明我正在使用MSYS2的CMake和GNU Make软件包,如here和here所述。
最佳答案
运行mingw64.exe
(不是msys2.exe
)。
确保安装以下软件包:mingw-w64-x86_64-cmake
mingw-w64-x86_64-make
mingw-w64-x86_64-suitesparse
和C/C++,Fortran编译器。
注意:所有已安装的软件包必须在mingw64目录中。
更改CMakeLists.txt中的WITH_MPI
值:
SET(WITH_MPI FALSE ...
查找cmake的路径并使用以下命令进行制作:
$ where cmake.exe
和$ where mingw32-make.exe
为了简单起见,请使用
alias
命令:alias my_cmake=/d/msys64/mingw64/bin/cmake.exe
alias my_make=/d/msys64/mingw64/bin/mingw32-make.exe
在elmer存储库中创建构建目录,然后:
my_cmake -G "MinGW Makefiles" ..
my_make
关于cmake - 通过 `add_subdirectory`添加的库遇到 “No rule to make target while compiling..”错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61164034/