Clone this wiki locally
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: http://keon.io/mlpack/mlpack-on-windows/ Another guide is written by kirizaki: https://overdosedblog.wordpress.com/2016/08/15/once_again/
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 https://github.com/VespucciProject/MLPACK_for_MSVC, 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:
~\OpenBLAS.0.2.14.1\lib\native\bin\x64\libgcc_s_seh-1.dll ~\OpenBLAS.0.2.14.1\lib\native\bin\x64\libgfortran-3.dll ~\OpenBLAS.0.2.14.1\lib\native\bin\x64\libopenblas.dll ~\OpenBLAS.0.2.14.1\lib\native\bin\x64\libquadmath-0.dll
~/OpenBLAS.0.2.14.1/lib/native/bin/x32/libgcc_s_seh-1.dll ~/OpenBLAS.0.2.14.1/lib/native/bin/x32/libgfortran-3.dll ~/OpenBLAS.0.2.14.1/lib/native/bin/x32/libopenblas.dll ~/OpenBLAS.0.2.14.1/lib/native/bin/x32/libquadmath-0.dll
Note: This step is of course optional, but it's easier than including each library as an
1. Create New Project
Create new project and paste example code from mlpack tutorials "mlpack Input and Output"
Warning1: Remember to change
Solution Configuration to
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
Generaland add mlpack, armadillo and boost include directories:
~/armadillo-7.400.1/include ~/boost.184.108.40.206/lib/native/include ~/mlpack-2.0.3/build/include
3. Compiler Additional Library Directories
The following folder is optional for easier including all libraries in
which consists of:
mlpack.lib/dll (depends on how mlpack and armadillo target was compiled) armadillo.lib/dll (same as above) ~/boost_math_c99-vc220.127.116.11.0/lib/native/address-model-64/lib/* ~/boost_program_options-vc18.104.22.168.0/lib/native/address-model-64/lib/* ~/boost_unit_test_framework-vc22.214.171.124.0/lib/native/address-model-64/lib/* ~/boost_serialization-vc126.96.36.199.0/lib/native/address-model-64/lib/* ~/boost_random-vc188.8.131.52.0/lib/native/address-model-64/lib/*
General and add
4. Linker Additional Dependencies
Input and add
Warning: Additional Dependencies (
mlpack.dll) should point to the same
.dll from Additional Library Directories (
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 . . .
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 ] [INFO ] Execution parameters: [INFO ] help: false [INFO ] info: "" [INFO ] verbose: true [INFO ] version: false [INFO ] [INFO ] Program timers: [INFO ] some_timer: 0.002928s [INFO ] total_time: 0.004584s Press any key to continue . . .
-v option (and others) can be done by going to
Debugging and setting
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 http://www.mlpack.org/files/mlpack-1.0.1.tar.gz $ tar -xzpf mlpack-1.0.1.tar.gz $ mkdir mlpack/build $ cd mlpack/build/ $ cmake ../ $ make
MSYS2 + QT
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...
More information might be found in the following Windows-related tickets:
- A search for Windows