Join GitHub today
GitHub is home to over 28 million developers working together to host and review code, manage projects, and build software together.Sign up
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.) Other compilers can also be used---icc, MSYS2, and clang/LLVM should all work. However, if a nightly build of clang is being used, it may require some manual configuration to integrate with Visual Studio.
The latest and verified guide how-to build mlpack 2.0.3 on Windows can be found on the blog of our contributor keon: http://keon.io/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.126.96.36.199/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-vc188.8.131.52.0/lib/native/address-model-64/lib/* ~/boost_program_options-vc184.108.40.206.0/lib/native/address-model-64/lib/* ~/boost_unit_test_framework-vc220.127.116.11.0/lib/native/address-model-64/lib/* ~/boost_serialization-vc18.104.22.168.0/lib/native/address-model-64/lib/* ~/boost_random-vc22.214.171.124.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 successful...
Notes for linking mlpack in applications
If you are having linking errors, you might consider the following steps:
In case of BLAS linking errors, add libopenblas.dll.a file from mlpack-x.y.z\packages\OpenBLAS.0.2.14.1\lib\native\lib\x64 or mlpack-x.y.z\packages\OpenBLAS.0.2.14.1\lib\native\lib\x32 (depending upon the configuration of the system) to "Additional Dependencies" of the project.
In case of the error "The program can't start because mlpack.dll is missing from your computer. Try reinstalling the program to fix this problem.": copy the mlpack.dll file from mlpack-x.y.z\build into the current project folder according to this IRC discussion.
More information might be found in the following Windows-related tickets:
- A search for Windows