Keon Kim edited this page Dec 20, 2016 · 14 revisions

mlpack On Windows

mlpack, while not designed with Windows as a specific target, can still be built and run on Windows without too much pain (with some exceptions). This document details the steps necessary to get mlpack compiled using Microsoft Visual Studio 2015. (Currently, mlpack will only build on Visual Studio 2015 and newer because of C++11 support issues.)

The latest and verified guide how-to build mlpack 2.0.3 on Windows can be found on the blog of our contributor keonkim: Another guide is written by kirizaki:

Warning: Some dependencies have been updated; i.e., Boost: the latest version is now 1.61 instead of 1.60. So you may need to update the instructions accordingly.

Other guides are also on Github; see, which is not up-to-date right now.

Unfortunately it seems that in some settings, mlpack will cause the Visual Studio compiler to issue C1001 errors (internal compiler errors; essentially bugs in the compiler): #219. One solution is to use the Intel C++ compiler instead of the Visual Studio compiler. Another way on Windows is to use MSYS2 that is providing a precompiled version of mlpack and related dependencies.

Using mlpack in other applications under Visual Studio 2015

If you want to write your own application and link mlpack against it, you will need to add the include directories of mlpack to your project and add mlpack.lib to the libraries you link against.

Let's do it according to keonkim's guide.


First of all the OpenBLAS libraries should be copied to C:/Windows/System32/ and those are:




And also libopenblas.dll.a from:


Note: This step is of course optional, but it's easier than including each library as an Additional Dependency.

1. Create New Project

Create new project and paste example code from mlpack tutorials "mlpack Input and Output"

Windows build step 1

Warning1: Remember to change Solution Configuration to Debug/Release & Solution Platform to x64/x86 - it's dependent from how mlpack & armadillo was build.

Warning2: Don't forget to include #include "stdafx.h" & #include <iostream> or just copy THIS paste.

2. Compiler Additional Include Directories

Go to Project > Properties > C/C++ > Generaland add mlpack, armadillo and boost include directories:


Windows build step 2

3. Compiler Additional Library Directories

The following folder is optional for easier including all libraries in VS15:


which consists of:

mlpack.lib/dll (depends on how mlpack and armadillo target was compiled)
armadillo.lib/dll (same as above)

Go to Project > Properties > Linker > General and add C:/projects/libs

Windows build step 3

4. Linker Additional Dependencies

Go to Project > Properties > Linker > Input and add C:/libraries/mlpack.lib

Windows build step 4

Warning: Additional Dependencies (mlpack.lib or mlpack.dll) should point to the same .lib/.dll from Additional Library Directories (C:/libraries/mlpack.lib or C:/libraries/mlpack.dll)

5. Compile & Run

Once the program is compiled and run, the output should be:

[WARN ] A warning!
[WARN ] Made it!
Press any key to continue . . .

Windows build step 5

or if you run the program in verbose mode with -v as an input argument:

[INFO ] Some test informational output.
[WARN ] A warning!
[WARN ] Made it!
[INFO ] Execution parameters:
[INFO ]   help: false
[INFO ]   info: ""
[INFO ]   verbose: true
[INFO ]   version: false
[INFO ] Program timers:
[INFO ]   some_timer: 0.002928s
[INFO ]   total_time: 0.004584s
Press any key to continue . . .

Windows build step 6

Setting the -v option (and others) can be done by going to Project > Properties > Debugging and setting Command Arguments: -v

Windows build step 8

Further Thoughts

Compiling mlpack on Windows is a tedious affair. Maybe your situation does not permit it, but perhaps you should consider using Linux (or another UNIX-like system, such as Mac OS X or FreeBSD or similar)? In those cases configuring and compiling mlpack is as simple as:

$ wget
$ tar -xzpf mlpack-1.0.1.tar.gz
$ mkdir mlpack/build
$ cd mlpack/build/
$ cmake ../
$ make


If you are getting strange errors linking your QT application with mlpack library as, for example, "undefined reference to `mlpack::Log::Assert(bool, std::string const&)'", try changing your compiler...

At least in one case it has been reported that using compilers provided with Qt4.8.7 (g++ 4.8.2) & Qt5.5.0 (g++ 4.9.2) fails... while using g++ 5.3.0 was succesfull...

Other Documentation

More information might be found in the following Windows-related tickets: