参考:https://github.com/xianyi/OpenBLAS/wiki/How-to-use-OpenBLAS-in-Microsoft-Visual-Studio
下载anaconda :https://www.anaconda.com/products/individual
下载OpenBLAS:https://sourceforge.net/projects/openblas/files/
gitclone版编译时会报错”missing)“
打开anaconda shell输入下面指令
conda update -n base conda
conda config --add channels conda-forge
conda config --set channel_priority flexible
conda install -y cmake flang clangdev perl libflang ninja
输入下面指令,这一步很重要否则会报错找不到kernal**.lib的错误,设置vs运行环境为x64(注意:进入anaconda命令行后不要cd到其他目录下,直接在根目录下运行,否则会报错“找不到vcvars.bat”):
"c:/Program Files (x86)/Microsoft Visual Studio/2019/Community/VC/Auxiliary/Build/vcvars64.bat"
设置cmake 工程环境 mkdir build cd build
set "LIB=%CONDA_PREFIX%\Library\lib;%LIB%"
set "CPATH=%CONDA_PREFIX%\Library\include;%CPATH%"
cmake .. -G "Ninja" -DCMAKE_CXX_COMPILER=clang-cl -DCMAKE_C_COMPILER=clang-cl -DCMAKE_Fortran_COMPILER=flang -DBUILD_WITHOUT_LAPACK=no -DNOFORTRAN=0 -DDYNAMIC_ARCH=ON -DCMAKE_BUILD_TYPE=Release
set 结束后可通过conda activate 查看设置,windows用户看不到结果
(base) C:\Windows\System32>conda activate
C:\Windows\System32>set "LIB="
C:\Windows\System32>set "CPATH="
C:\Windows\System32>set "_LIB="
C:\Windows\System32>set "_CPATH="
C:\Windows\System32>if "D:\ProgramData\Anaconda3" == "" set "LIB=;\Library\lib"
C:\Windows\System32>if "D:\ProgramData\Anaconda3" == "" set "CPATH=;\Library\include"
C:\Windows\System32>if not "D:\ProgramData\Anaconda3" == "" set "LIB=;D:\ProgramData\Anaconda3\Library\lib"
C:\Windows\System32>if not "D:\ProgramData\Anaconda3" == "" set "CPATH=;D:\ProgramData\Anaconda3\Library\include"
Build the project
cmake --build . --config release
Install all relevant files created by the build
cmake --install . --prefix "C:\Program Files (x86)\OpenBLAS" -v
新建环境变量 OpenBLAS_HOME C:\Program Files (x86)\OpenBLAS
OpenBLAS C:\Program Files (x86)\OpenBLAS