Fay
Fay

Reputation: 105

CMake can not find LAPACK library on windows

I'm trying to build a C++ project using CMake which includes LAPACK library on a win32 system.

Following the documentary LAPACK for windows,

I installed MinGW 32 bits and added "C:\MinGW\bin" in the path, then put downloaded pre-built libraries: libblas.lib, libblas.dll, liblapack.lib, liblapack.dll in the path "\projectRoot\3rdparty\LAPACK"

The structure of folders is as below:

\projectRoot
    \CMakeLists.txt
    \3rdparty
         \LAPACK
             libblas.lib
             ...

in the CMakeLists file, I added

set(LAPACK_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/LAPACK")
find_package(LAPACK REQUIRED)

but got error:

CMake Error at C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:146 (message):
  Could NOT find BLAS (missing: BLAS_LIBRARIES)
Call Stack (most recent call first):
  C:/Program Files/CMake/share/cmake-3.16/Modules/FindPackageHandleStandardArgs.cmake:393 (_FPHSA_FAILURE_MESSAGE)
  C:/Program Files/CMake/share/cmake-3.16/Modules/FindBLAS.cmake:810 (find_package_handle_standard_args)
  C:/Program Files/CMake/share/cmake-3.16/Modules/FindLAPACK.cmake:197 (find_package)
  CMakeLists.txt:17 (find_package)

and before the error, there's something that CMake couldn't find

Looking for sgemm_
Looking for sgemm_ - not found
Looking for pthread.h
Looking for pthread.h - not found
Found Threads: TRUE  

I can't figure out what's the cause of the problem.

Thank you in advance if you could share your experience.

Upvotes: 0

Views: 5910

Answers (1)

Fay
Fay

Reputation: 105

Answer my own question.

Finally what I did to find the package was:

Copy a built version from jlblancoc/suitesparse-metis-for-windows, then use config mode of find_package by

set(LAPACK_DIR "dir/to/lapacklibs")
find_package(LAPACK CONFIG REQUIRED)

Upvotes: 1

Related Questions