mlpack  3.4.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages
Building mlpack From Source on Windows

Introduction

This tutorial will show you how to build mlpack for Windows from source, so you can later create your own C++ applications. Before you try building mlpack, you may want to install mlpack using vcpkg for Windows. If you don't want to install using vcpkg, skip this section and continue with the build tutorial.

PS> .\vcpkg install mlpack:x64-windows

After installing, in Visual Studio, you can create a new project (or open an existing one). The library is immediately ready to be included (via preprocessor directives) and used in your project without additional configuration.

Build Environment

This tutorial has been designed and tested using:

The directories and paths used in this tutorial are just for reference purposes.

Pre-requisites

Windows build instructions

Dependencies

OpenBLAS Dependency

Boost Dependency

You can either get Boost via NuGet or you can download the prebuilt Windows binaries separately. This tutorial follows the second approach for simplicity.

Note
Make sure you download the MSVC version that matches your Visual Studio

Armadillo Dependency

cmake -G "Visual Studio 16 2019" -A x64 -DBLAS_LIBRARY:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" -DLAPACK_LIBRARY:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" ..
Note
If you are using different directory paths, a different configuration (e.g. Release) or a different VS version, update the cmake command accordingly. If CMake cannot identify the compiler version, check if the Visual Studio compiler and Windows SDK are installed correctly.

Building mlpack

cmake -G "Visual Studio 16 2019" -A x64 -DBLAS_LIBRARIES:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" -DLAPACK_LIBRARIES:FILEPATH="C:/mlpack/mlpack/packages/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a" -DARMADILLO_INCLUDE_DIR="C:/mlpack/armadillo/include" -DARMADILLO_LIBRARY:FILEPATH="C:/mlpack/armadillo/build/Debug/armadillo.lib" -DBOOST_INCLUDEDIR:PATH="C:/boost/" -DBOOST_LIBRARYDIR:PATH="C:/boost/lib64-msvc-14.2" -DDEBUG=OFF -DPROFILE=OFF ..
Note
cmake will attempt to automatically download the ensmallen dependency. If for some reason cmake can't download the dependency, you will need to manually download ensmallen from http://ensmallen.org/ and extract it to "C:\mlpack\mlpack\deps\". Then, specify the path to ensmallen using the flag: -DENSMALLEN_INCLUDE_DIR=C:/mlpack/mlpack/deps/ensmallen/include

You are ready to create your first application, take a look at the Sample C++ ML App

Appendix

If you prefer to use cmake GUI, follow these instructions:

Additional Information

If you are facing issues during the build process of mlpack, you may take a look at other third-party tutorials for Windows, but they may be out of date:

Github wiki Windows Build page
Keon's tutorial for mlpack 2.0.3
Kirizaki's tutorial for mlpack 2