Friday, September 5, 2014

How to run netlib-java/breeze in native mode with BLAS/Lapack binaries on Windows 7 x64

Netlib-java allows fast linear algebra in native mode with BLAS/LAPACK libraries. Breeze is for Scala and is based on netlib as well. The problem is where to get binaries and how to set up netlib-java. So, which libraries are needed?
  • libquadmath-0.dll //MINGW
    libwinpthread-1.dll //MINGW
    libgcc_s_seh-1.dll //MINGW
    libgfortran-3.dll //MINGW
    liblapack3.dll //OpenBLAS copy of libopeblas.dll
    libblas3.dll //OpenBLAS copy of libopenblas.dll
    netlib-native_system-win-x86_64.dll //netlib-java
So, few libs from MINGW, one from OpenBLAS copied two times and one from netlib-java. It is important that all libraries have the same architecture: x64 (or x32). Mixing doesn't work. Here are the links where these libraries exist pre-compiled:


You need to place the needed dlls into the project folder or to some folder that is in PATH. Your maven pom project must have the following entry if you use only netlib-java:
  •       <dependency>
              <groupId>com.github.fommil.netlib</groupId>
              <artifactId>all</artifactId>
              <version>1.1.2</version>
          </dependency>
or if you use breeze:
  •     <dependency>
          <groupId>org.scalanlp</groupId>
          <artifactId>breeze_${scala.binary.version}</artifactId>
          <version>0.9</version>
        </dependency>
      <dependency>
              <groupId>com.github.fommil.netlib</groupId>
              <artifactId>all</artifactId>
              <version>1.1.2</version>
      </dependency>
Another option would be to compile OpenBLAS. You will need MINGW64, OpenBLAS sources plus MSYS64: http://sourceforge.net/projects/mingw-w64/files/External%20binary%20packages%20%28Win64%20hosted%29/MSYS%20%2832-bit%29/ (more details at https://code.google.com/p/tonatiuh/wiki/InstallingMinGWForWindows64)

  • unzip OpenBLAS sources
  • extract MINGW and MSYS in the same folder, 
  • run msys.bat from MINGW/MSYS folder
  • cd to OpenBLAS sources dir and run "make BINARY=64". After a while you'll get libopenblas.dll