Skip to content

Instantly share code, notes, and snippets.

@thirdwing
Last active August 29, 2015 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save thirdwing/e3e0cd0843e7945e9013 to your computer and use it in GitHub Desktop.
Save thirdwing/e3e0cd0843e7945e9013 to your computer and use it in GitHub Desktop.

#mlpack on Windows

mlpack, while not designed with Windows as a specific target, can still be built and run on Windows with some configuration. This document details the steps necessary to get MLPACK compiled using MinGW64.

#Prerequisites

  • MinGW64: The compiler we use. Please add it into PATH
  • boost: This is the boost 1.56 static library compiled by myself using MinGW64. Static library is a better choice on Windows.
  • Armadillo
  • BLAS and lapack: Static BLAS and lapack library which are needed by Armadillo. Compiled using MinGW64
  • local300.zip: This is from R project, which provides static library and header files for libraries which are not easy to compile on Windows, including zlib, libxml and iconv.
  • CMake: Please add it into PATH

#Configuration

There are some configuration we need, since all the libraries we are using is static library.

First, change this line into

set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} -O3 -DLIBXML_STATIC")
SET(CMAKE_LINK_LIBRARY_SUFFIXES .a)

LIBXML_STATIC is used to tell compiler we are using the static libxml, which is necessary.

Second, change this line into

link_directories(PATH_TO_LIB_FILES)
target_link_libraries(mlpack
  liblapack.a
  libboost_program_options-mgw48-s-1_56.a
  libboost_unit_test_framework-mgw48-s-1_56.a
  librefblas.a
  libgfortran
  libxml2.a
  libz.a
  libiconv.a
  Ws2_32
)

Please set PATH_TO_LIB_FILES according to your system.

#Compile

To compile mlpack using CMake is almost the same with Linux, except you need tell cmake we are using MinGW64

mkdir build
cd build
cmake -G "MinGW Makefiles" ..
mingw32-make
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment