After a tedious journey of making mlpack work on windows, I want to write down the steps of how to compile mlpack, so I will never forget it.
The steps to compile mlpack-1.0.12 are:
- Visual studio 2015 would not install the c++ compiler by default, you need to select the custom install and select c++ by yourself
- After you install vs2015, execute following command on command window,[
copy "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\mspdbsrv.exe"
"C:\Program Files (x86)\Microsoft Visual Studio 14.0\Common7\IDE"
], this could fix a link issues( link.exe complains that MSPDB140.dll has the wrong version installed)
- extract source codes(ex : c:/libxml2-2.9.2)
- go to the folder c:/libxml2-2.9.2 and copy the configure.ac to configure.in
- go to the folder c:/libxml2-2.9.2/win32
- open command prompt and enter cscript configure.js compiler=msvc iconv=no zlib=no debug=no
- enter command "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
- enter command nmake /f Makefile.msvc install
- extract source codes(ex : c:/zlib-1.2.8)
- go to the folder c:/zlib-1.2.8
- enter command "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86_amd64
- enter command
nmake -f win32/Makefile.msc AS=ml64 LOC="-DASMV -DASMINF -I." OBJA="inffasx64.obj gvmat64.obj inffas8664.obj"
Download the zip file from source forge, open visual studio 2015 and compile, you will need an account of source forge to download this file
5 : cmake3.3.2 or newer(start from 3.3.2, cmake support CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS)
6 : install mingw-w64(I use mingw-w64 5.1.0 in this post)
7 : lapack3.5.0--I have heard that openBLAS or intel mkl are faster than the blas come with lapack, but in this post I will use the blas come with lapack3.5.0
- extract source codes(ex : c:/lapack3.5.0)
- go to the folder c:/lapack3.5.0
- add commands in CMakeLists.txt
- open the CMakeLists.txt by cmake-gui
- setup the native compilers of c, c++ and fortran as "x86_64-w64-mingw32-gcc.exe", "x86_64-w64-mingw32-g++.exe", "x86_64-w64-mingw32-gfortran.exe"
- Disable BUILD_STATIC_LIBS and enable BUILD_SHARED_LIBS under the lable BUILD
- Set the value(under label Ungrouped Entries) VCVARSAMD64 as "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/vcvarsx86_amd64.bat"
- Set the value(under label CMake) CMake_GNUtoMS_VCVARS as "C:/Program Files (x86)/Microsoft Visual Studio 14.0/VC/bin/x86_amd64/vcvarsx86_amd64.bat"
- Click Configure until all white
- Click generate
- Open the vcproject files and build
- BLAS is good, but openBLAS is much more faster than BLAS, it is almost three times faster on my laptop(Y410P)
- Download msys
- Clone openBLAS(git clone git://github.com/xianyi/OpenBLAS.git)
- Setup the environment path of MSYS(ex : C:\msys)
- Open command prompt
- Go to the folder of openBLAS(ex : C:\OpenBLAS)
- Type mingw32-make
- You will find the .a and .dll under the folder C:\OpenBLAS
- extract source codes(ex : c:/armadillo-5.600.2)
- go to the folder c:/aramadillo-5.600.2
- open CMakeLists.txt by nodepad and add three lines set(CMAKE_WINDOWS_EXPORT_ALL_SYMBOLS ON)
add_definitions(-DARMA_64BIT_WORD)
add_definitions(-DNOMINMAX) - open the CMakeLists.txt by cmake-gui
- Set the value(under label Ungrouped Entries) BLAS_LIBRARY(ex : "C:/Users/yyyy/Qt/3rdLibs/lapack/lapack-3.5.0/bin/vc2015_x86_amd64/release/libopenblas.dll.a")
- Set the value(under label Ungrouped Entries) LAPACK_LIBRARY(ex : "C:/Users/yyyy/Qt/3rdLibs/lapack/lapack-3.5.0/bin/vc2015_x86_amd64/release/liblapack.lib")
- Click Configure until all white
- Click generate
- Open the vcproject files and build
- Just download and unzip, the community already build it for us
- extract source codes(ex : c:/mlpack-1.0.12)
- go to the folder c:/mlpack-1.0.12
- Specify the path of the libraries, dll and setup some definition, the details can found at here(start from line 66~87)
- Click Configure until all white
- Click generate
- Open the vcproject files and build
- If there are link error, specify the path of openblas, lapack, libxml2 by cmake-gui(under label Ungrouped Entries, I do not know why the set command can not work yet), configure and generate again
No comments:
Post a Comment