(macOS Big Sur)CMake找不到BLAS(缺少:BLAS_LIBRARIES)



我正在尝试在macOS上制作MultiNest/pymultinest;这个程序需要openblas和lapack作为依赖项。我使用自制软件安装了这两个软件,但当我尝试在MultiNest构建目录中cmake时,我会收到以下错误:

CMake Error at /usr/local/Cellar/cmake/3.20.5/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:230 (message):
Could NOT find BLAS (missing: BLAS_LIBRARIES)
Call Stack (most recent call first):
/usr/local/Cellar/cmake/3.20.5/share/cmake/Modules/FindPackageHandleStandardArgs.cmake:594 (_FPHSA_FAILURE_MESSAGE)
/usr/local/Cellar/cmake/3.20.5/share/cmake/Modules/FindBLAS.cmake:1045 (find_package_handle_standard_args)
/usr/local/Cellar/cmake/3.20.5/share/cmake/Modules/FindLAPACK.cmake:265 (find_package)
/usr/local/Cellar/cmake/3.20.5/share/cmake/Modules/FindLAPACK.cmake:291 (_lapack_find_dependency)
src/CMakeLists.txt:31 (FIND_PACKAGE)

我已经声明了许多路径;

export LDFLAGS="-L/usr/local/opt/openblas/lib"
export CPPFLAGS="-I/usr/local/opt/openblas/include"
export PKG_CONFIG_PATH="/usr/local/opt/openblas/lib/pkgconfig"
export LDFLAGS="-L/usr/local/opt/lapack/lib"
export CPPFLAGS="-I/usr/local/opt/lapack/include"
export PKG_CONFIG_PATH="/usr/local/opt/lapack/lib/pkgconfig"
export LD_LIBRARY_PATH=/usr/local/opt/openblas:$LD_LIBRARY_PATH
export BLAS=/usr/local/opt/openblas/lib/libopenblas.a

为什么cmake在macOS上找不到BLAS?非常感谢。

您需要将/usr/local/opt/lapack/usr/local/opt/openblas添加到CMAKE_PREFIX_PATH中,如下所示:

$ cmake -S . -B build -DCMAKE_BUILD_TYPE=Release 
-DCMAKE_PREFIX_PATH="/usr/local/opt/lapack;/usr/local/opt/openblas"

Homebrew没有将它们符号链接到/usr/local,以避免与苹果自己的Accelerate.framework BLAS实现发生冲突。这种包装被称为";只有小桶";用Homebrew的话说。

您还应该取消设置所设置的所有环境变量,因为CMake负责设置include和库路径。

感兴趣的文档链接:

  • CMake搜索过程:https://cmake.org/cmake/help/latest/command/find_package.html#search-程序
  • 环境变量CMake方面:https://cmake.org/cmake/help/latest/manual/cmake-env-variables.7.html
  • FindBLAS模块:https://cmake.org/cmake/help/latest/module/FindBLAS.html
  • FindLAPACK模块:https://cmake.org/cmake/help/latest/module/FindLAPACK.html

相关内容

  • 没有找到相关文章

最新更新