0

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.

Fay
  • 105
  • 1
  • 5
  • The BLAS and LAPACK packages are separate, and must be found and linked individually. From your linked instructions: "*Link your C application built with MSVC with the BLAS and LAPACK libraries...*". You haven't shown your entire CMake file, but did you also call `find_package(BLAS REQUIRED)` before finding LAPACK? – Kevin Jun 16 '20 at 13:12
  • @squareskittles Thank you. So I tried added `set(BLAS_DIR "${CMAKE_CURRENT_SOURCE_DIR}/3rdparty/LAPACK")` and `find_package(BLAS REQUIRED)` but still got the same error – Fay Jun 16 '20 at 16:54
  • I was thinking maybe it's caused by the prefix of the libraries I downloaded. So I added `set(CMAKE_FIND_LIBRARY_PREFIXES "lib")`, but didn't work neither... – Fay Jun 16 '20 at 20:46

1 Answers1

1

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)
Fay
  • 105
  • 1
  • 5