HowTo build OpenBLAS with Native (MSVC) ABI

mathematics computation
Photo by Antoine Dautry / Unsplash

Prerequisite:

  1. Open you prefer commmand line prompt with Admin access(cmd, powershell...etc).

  2. Switch to your target build directory.

  3. Run command as below:

    $ conda update -n base conda
    $ conda config --add channels conda-forge
    $ conda install -y cmake flang clangdev perl libflang
    $ conda install -y -c isuruf kitware-ninja
    
  4. Activate the MSVC environment for 64 bits with vcvarsall64.bat. Its default path would be:
    C:/Program Files(x86)/Microsoft/Visual Studio/2017/Community/VC/Auxiliary/Build/vcvars64.bat
    Type link to check the environment is active or not.

  5. Now configure the project with CMake. (You can replace %CONDA_INSTALL_LOCN% with your actual anaconda install path)

    $ set "LIB=%CONDA_INSTALL_LOCN%\Library\lib;%LIB%"
    $ set "CPATH=%CONDA_INSTALL_LOCN%\Library\include;%CPATH%
    $ mkdir build
    $ cd build
    $ 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
    
  6. Build the project.

    $ cmake --build . --config Release
    

Now you can enjoy your high-speed Linear Algebra calculation.
Remember to add the path into environment variable if needed.


Reference

  1. https://github.com/xianyi/OpenBLAS/wiki/How-to-use-OpenBLAS-in-Microsoft-Visual-Studio

Related Article