2

I'm trying to use LAPACK in a Fortran project, but I can't get CMake to find my LAPACK dll. I have very little experience with Fortran, Cmake and linking dll's. I use this template for my project. In the main CMakeLists.txt file, I enabled the option

INCLUDE(${CMAKE_MODULE_PATH}/SetUpLAPACK.cmake)

but I get the following error

Could NOT find BLAS (missing: BLAS_LIBRARIES)

when trying to compile the project. I have tried to put the libblas.dll and liblapack.dll (I got them from this website) in different folders which are on in the PATH. I also tried putting them directly in the folder where the executables should be generated, but I still get the same error.

So my question is: How can I properly install LAPACK on my system, so that the compiler can find it and successfully compile the project?

I use gfortran (MinGW64) and Windows 10/11.

Devoev
  • 374
  • 1
  • 10

1 Answers1

4

Best/easiest option AFAICT is to replace MinGW64 with MSYS2, then you can just install lapack with it's package manager:

pacman -Sy mingw-w64-x86_64-lapack

(you should be able to install the MSYS2 gcc/gfortran toolchain as its dependency): the library will be placed in MSYS's shared library folder.

Otherwise, most likely you'll have to build it yourself.

Federico Perini
  • 1,414
  • 8
  • 13
  • Thanks for the answer. I did this, but I still get the same error. Do I have to somehow tell CMake, that I want to use the Compiler installed using MSYS2? I tried using the SET(CMAKE_C_COMPILER) command, but it didn't work for me – Devoev Jun 29 '22 at 11:34
  • based on (https://stackoverflow.com/questions/62408657/cmake-can-not-find-lapack-library-on-windows)[this answer] you may try manually setting the lapack directory to MSYS2's lib (something like `C:\msys64\mingw64\lib`) – Federico Perini Jun 29 '22 at 12:53
  • Unfortunately it still doesn't work. I don't get the Blas not found error anymore, but instead while building the project it says, that "dgesv" is not recognized (dgesv is a Lapack function). I tried uninstalling all fortran compilers on my system and reinstalling it using MSYS2, but now I get the error: CMake Error: Error required internal CMake variable not set, cmake may not be built correctly. Missing variable is: CMAKE_Fortran_PREPROCESS_SOURCE – Devoev Jun 30 '22 at 12:44