Skip to content

CBLAS for Windows

Miguel Lloreda edited this page Oct 7, 2017 · 6 revisions

This page will have instructions for building CBLAS implementations for windows.

Build Instructions for following implementations are currently available. If you are contributor and was able to successfully use CBLAS implementation other than the one listed below, please update the wiki with necessary details.

OpenBLAS

Source build

Follow the below steps to build OpenBLAS for Windows 8.1 64-bit. You would require cygwin installation with 64-bit MinGW compilers for x86_64 architecture.

  1. Download cygwin from here and make sure you install x86_64-w64-mingw32-gcc-* and x86_64-w64-mingw32-gfortran compiler packages. It would be better if you install all standard dev packages to avoid hiccups in the build process. Also, make sure <cygwin_install_root>/bin is added to your path so that any cygwin dlls required by OpenBLAS library would be found later.
  2. Launch cygwin64 terminal and change directory to where your git repositories are generally cloned.
  3. git clone git@github.com:xianyi/OpenBLAS.git
  4. cd OpenBLAS
  5. make BINARY=64 CC=/usr/bin/x86_64-w64-mingw32-gcc-4.8.3.exe FC=/usr/bin/x86_64-w64-mingw32-gfortran.exe. This step by itself will take from fifteen to twenty minutes. So, you can take a break.
  6. mkdir -p package
  7. make PREFIX=./package install. Now you should be seeing three folders created under package folder.
    • bin - libopenblas.dll
    • include - openblas headers
    • lib - library files
  8. Launch Visual Studio Command Prompt for x64 and change working directory to OpenBLAS/exports on your machine. You need to go here to create .lib file required by Visual Studio to compile with OpenBLAS.
  9. lib.exe /machine:x64 /def:libopenblas.def. This will create two files,
    • libopenblas.exp - Exports Library File
    • libopenblas - Object File Library
  10. Copy the two files generated in step 9 to OpenBLAS/package/lib.

Now, OpenBLAS/package is your OpenBLAS installation root which should be later used during ArrayFire CMake build configuration.

Make sure to add OpenBLAS/package/bin folder full path to the windows PATH environment variable so that any mingw DLLs required by OpenBLAS can be located by any executable that requires it.

Pre-built binaries (x86_64)

If you don't wish to compile the OpenBLAS source distribution, it is possible to use the pre-built binaries provided by the project by following the steps below:

  1. Visit the OpenBLAS project page (http://www.openblas.net/) and download the latest source archive (eg: http://sourceforge.net/projects/openblas/files/v0.2.12/)
  • Note: on 64bit Windows you should use the "int32" build (OpenBLAS-<version>-Win64-int32), so that the types used in OpenBLAS' headers are compatible with Arrayfire. Otherwise the BLAS backend won't build without manually editing openblas_config.h and setting the blasint typedef to int (or commenting out #define OPENBLAS_USE64BITINT).
  1. Download DependencyWalker (http://www.dependencywalker.com/)
  2. Extract the OpenBlas and DependencyWalker archives
  3. Run DependencyWalker (depends.exe) and open libopenblas.dll (in the "bin" directory)
  4. In the function list view, press CTRL+A to select all the entries, then right-click and "Copy Function Names"
  5. Create a new text file called libopenblas.txt in the same directory as libopenblas.dll, edit it and paste in the list of functions
  6. At the very top of the file (first line), insert "EXPORTS" on a line by its own. Example:
		EXPORTS
		caxpy
		caxpy_
		CAXPY
		ccopy
		ccopy_
		CCOPY
		...
  1. Rename the file to libopenblas.def
  2. Open the Visual Studio Developer Console (x64) in the same directory and run: lib.exe /machine:x64 /def:libopenblas.def

There will now be a valid libopenblas.lib file available.

Finally, if you don't have a MinGW distribution installed, you will need the DLLs provided in the mingw64_dll.zip archive.