Skip to content

Build Instructions for Windows

John Melonakos edited this page Nov 6, 2023 · 30 revisions

Overview:

Prerequisites

  • Microsoft Visual Studio 2015 or later
  • CMake v3.5.1 and above
  • vcpkg (latest version)

We recommend using vcpkg to install necessary dependencies for each of ArrayFire's backends: CPU, CUDA, and OpenCL.

Backend-independent

All backends require FreeImage >= 3.16.

vcpkg install --triplet x64-windows freeimage

Graphics support

vcpkg install --triplet x64-windows glfw3 freetype

Using freetype installed using the above command is sufficient for developement purposes.

  • Graphics support is enabled at runtime depending on availability of forge and respective dependencies.
  • For development purposes, forge can be built as part of ArrayFire build using the cmake option AF_BUILD_FORGE.
  • Forge, our high-performance visualization library, is automatically downloaded and built as an external project by CMake.
  • GLFW (>= 3.0.4)

CPU backend

vcpkg install --triplet x64-windows freeimage openblas fftw3
  • Alternative BLAS libraries: MKL and LAPACKE
  • Alternative FFT libraries: MKL and ACML 6.1 iFortran (known to fail FFT tests)

CUDA backend

vcpkg install --triplet x64-windows boost freeimage

In addition to Boost (>= v1.51) and FreeImage, you will also need:

  • Latest CUDA drivers. Note: There are known issues with 37x drivers.
  • CUDA Toolkit >= 9.0
  • Note: Visual Studio 2017 (v15.5 and above) comes with platform toolset v141, which NVCC does not support as of v9.1.
    • Follow these instructions to install the v140 platform toolset.
    • Follow the build instructions below to configure the project to point to the v140 toolset.

oneAPI backend

Required: Install oneAPI Base Toolkit with compiler and libraries.

Once the toolkit is installed, enable necessary paths to all compilers and libraries by running the setvars script. For example:

"C:\Program Files (x86)\Intel\oneAPI\setvars.bat"

Building the oneAPI backend requires setting the AF_BUILD_ONEAPI=1 CMake option since the oneAPI backend is disabled by default.

OpenCL backend

vcpkg install --triplet x64-windows boost freeimage openblas

In addition to Boost (>= v1.48), FreeImage, and a host-side BLAS library (openblas, in this instance), you will also need to install one of the available OpenCL SDKs along with Python 2.

Note: clBLAS, clFFT and Boost.Compute are automatically downloaded and built by CMake.

ArrayFire Build Instructions

1. Configure ArrayFire

cd arrayfire
mkdir build
cd build
cmake -G "Visual Studio 15 2017 Win64" -DCMAKE_TOOLCHAIN_FILE="<vcpkg_dir>\scripts\buildsystems\vcpkg.cmake" ..

If you are building the CUDA backend with Visual Studio 2017 (v15.5 and above), you will need to point to the v140 toolset during the configuration step:

cmake -Tv140 -G "Visual Studio 15 2017 Win64" -DCMAKE_TOOLCHAIN_FILE="<vcpkg_dir>\scripts\buildsystems\vcpkg.cmake" ..

Consult with the "CUDA backend" section above for how to download and install the v140 toolset in Visual Studio 2017.

2. Build ArrayFire

Once ArrayFire has been configured, you may build ArrayFire by opening the build\ArrayFire.sln file in Visual Studio.

After Build/Install

Our Using ArrayFire on Microsoft Windows with Visual Studio details how to setup a development environment with ArrayFire projects.

Known Dependency Compatibility Issues

  • Boost - Version 1.71 is known to have build issues when using Visual Studio 2019 version. Kindly upgrade boost to 1.72 which has the fix for this compilation error.