-
-
Notifications
You must be signed in to change notification settings - Fork 1.6k
WindowsBuild
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.
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
or
~/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
And also libopenblas.dll.a
from:
~/OpenBLAS.0.2.14.1/lib/native/lib/x64/libopenblas.dll.a
Note: This step is of course optional, but it's easier than including each library as an Additional Dependency
.
Create new project and paste example code from mlpack tutorials "mlpack Input and Output"
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.
Go to Project
> Properties
> C/C++
> General
and add mlpack, armadillo and boost include directories:
~/armadillo-7.400.1/include ~/boost.1.61.0.0/lib/native/include ~/mlpack-2.0.3/build/include
The following folder is optional for easier including all libraries in VS15
:
C:/projects/libs
which consists of:
mlpack.lib/dll (depends on how mlpack and armadillo target was compiled) armadillo.lib/dll (same as above) ~/boost_math_c99-vc140.1.60.0.0/lib/native/address-model-64/lib/* ~/boost_program_options-vc140.1.60.0.0/lib/native/address-model-64/lib/* ~/boost_unit_test_framework-vc140.1.60.0.0/lib/native/address-model-64/lib/* ~/boost_serialization-vc140.1.60.0.0/lib/native/address-model-64/lib/* ~/boost_random-vc140.1.60.0.0/lib/native/address-model-64/lib/*
Go to Project
> Properties
> Linker
> General
and add C:/projects/libs
Go to Project
> Properties
> Linker
> Input
and add C:/libraries/mlpack.lib
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
)
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 . . .
Setting the -v
option (and others) can be done by going to Project
> Properties
> Debugging
and setting Command Arguments
: -v
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
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...
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:
- #881
- #865
- #613
- #200
- #211
- #212
- #213
- #214
- A search for Windows