Xgboost: how to build libxgboost.dll by msvc ?

Created on 30 Mar 2016  Â·  18Comments  Â·  Source: dmlc/xgboost

hi, i want install xgboost on windows 10 by vs2015, after read the installation guide, i know i just need build a libxgboost.dll, but I cannot found any useful messages about build this dll file by mcvs, however, i google the installation way, most of the answer like these, cd to xgboost/windows, or xgboost/xgboost-master, then build ......but there are no windows/xgboost-master folder in xgboost ...

Most helpful comment

@leoli2012

This approach work for me, I spent a lot of hours trying to compile, and this is working on latest xgboost on win7 and win10 (64bit!):

0] recommanding delete all previos instalation of python, mingw64, xgboost :), but you know, it is up to you

1] install git for win (with git bash)
2] install python (I used anaconda, 3.5.1, 64bit - recommanding)
3] as admin update anaconda:
$ conda update conda
$ conda update scikit-learn (not necessary, but I used it next to xgboost)
4] download this as only this version of mingw :) - this is crucial part..
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.1/threads-posix/seh/x86_64-4.9.1-release-posix-seh-rt_v3-rev2.7z

  • do not ask why, it just works :)

5] extract to: c://mingw64//
6] in c://mingw64//bin// locate "mingw32-make.exe" and rename to "make.exe"
7] add this "c://mingw64//bin//" to enviroment PATH
8] restart PC
9] open git bash as admin

10] and now xgboost:

$ git clone --recursive https://github.com/dmlc/xgboost
$ cd xgboost
$ git submodule init
$ git submodule update
$ cd dmlc-core
$ make -j4
$ cd ../rabit
$ make lib/librabit_empty.a -j4
$ cd ..
$ cp make/mingw64.mk config.mk
$ make -j4

11] for python module
cd python-package
python setup.py install

12] launch python and enjoy :)
import xgboost
..

All 18 comments

reference https://github.com/dmlc/xgboost/issues/736, seems windows folder is obsoleted, cmake/mingw is the only way in window, i will try~

tutorial from ibm blog is working, check comments here:

https://github.com/dmlc/xgboost/issues/1049

check this. http://www.thushv.com/uncategorized/i-knew-you-were-trouble-xgboost-windows-a-proper-guide/
Downdrade to V 4.0 stable (not the v4.X) using git commit. Then you will get the old VS projects and the wrapper.

0.4 stable via VS is working, but there is nice feature in master branch: setting learning_rate different for each boosting round...

@gugatr0n1c @thusithaC thanks for your help~ i installed git for windows and mingw64, added mingw64/bin to system path, open git bash, exec following commands
$ git clone --recursive https://github.com/dmlc/xgboost
$ cd xgboost
$ git submodule init
$ git submodule update
$ alias make='mingw32-make'
$ make -j4
however ,make fail for below erros~
g++ -m64 -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -DDMLC_ENABLE_STD_THREAD=0 -Idmlc-core/include -Irabit/include -fopenmp -MM -MT build/c_api/c_api_error.o src/c_api/c_api_error.cc >build/c_api/c_api_error.d
g++ -m64 -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -DDMLC_ENABLE_STD_THREAD=0 -Idmlc-core/include -Irabit/include -fopenmp -MM -MT build/learner.o src/learner.cc >build/learner.d
g++ -m64 -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -DDMLC_ENABLE_STD_THREAD=0 -Idmlc-core/include -Irabit/include -fopenmp -MM -MT build/logging.o src/logging.cc >build/logging.d
g++ -m64 -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -DDMLC_ENABLE_STD_THREAD=0 -Idmlc-core/include -Irabit/include -fopenmp -MM -MT build/common/common.o src/common/common.cc >build/common/common.d
g++ -m64 -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -DDMLC_ENABLE_STD_THREAD=0 -Idmlc-core/include -Irabit/include -fopenmp -c src/common/common.cc -o build/common/common.o
g++ -m64 -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -DDMLC_ENABLE_STD_THREAD=0 -Idmlc-core/include -Irabit/include -fopenmp -c src/c_api/c_api_error.cc -o build/c_api/c_api_error.o
g++ -m64 -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -DDMLC_ENABLE_STD_THREAD=0 -Idmlc-core/include -Irabit/include -fopenmp -c src/logging.cc -o build/logging.o
g++ -m64 -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -DDMLC_ENABLE_STD_THREAD=0 -Idmlc-core/include -Irabit/include -fopenmp -c src/learner.cc -o build/learner.o
In file included from include/xgboost/./base.h:10:0,
from include/xgboost/logging.h:13,
from src/logging.cc:7:
dmlc-core/include/dmlc/omp.h:9:17: fatal error: omp.h: No such file or directory
compilation terminated.
Makefile:97: recipe for target 'build/logging.o' failed
mingw32-make: ** [build/logging.o] Error 1
mingw32-make: *
* Waiting for unfinished jobs....
In file included from include/xgboost/./base.h:10:0,
from include/xgboost/logging.h:13,
from src/learner.cc:7:
dmlc-core/include/dmlc/omp.h:9:17: fatal error: omp.h: No such file or directory
compilation terminated.
Makefile:97: recipe for target 'build/learner.o' failed
mingw32-make: *** [build/learner.o] Error 1
dmlc-core/include/dmlc/omp.h is exist in fact~

i try to make in another way, cp make/mingw.mk dmle-core/config.mk, and then cd dmlc-core/ to make -j4 ,but also meet the same problem,

Hi,

Is this the V4.0 or V4.x ? The latter I still cant compile successfully
using mingw64.

One more trick, someone mentioned making the alias 'make' is not enough.
Try going to the mingw/bin folder and making a copy of ming32-make file and
renaming it to make.

Good luck.

On Thu, Mar 31, 2016 at 7:08 PM, leoli2012 [email protected] wrote:

i try to make in another way, cp make/mingw.mk dmle-core/config.mk, and
then cd dmlc-core/ to make -j4 ,but also meet the same problem,

—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/dmlc/xgboost/issues/1063#issuecomment-203880518

Thusitha Chandrapala

Hi leoli2021,

I managed to get things running for V4.x. Yei!!! With mingw64.

One problem was having the mingw path in "/Program files.../". Somehow spaces seems to mess up the make file.

So,
1) make sure all path names are without spaces
2) try renaming mingw32-make to make
3) try getting a fresh copy from git, and those submodule commands correctly. your initial error seems to be because omp.h is missing. I have that file in the correct location. So go check the folder to see if the file is there..
4) and use "cp make/mingw64.mk config.mk; make -j4"

@leoli2012

This approach work for me, I spent a lot of hours trying to compile, and this is working on latest xgboost on win7 and win10 (64bit!):

0] recommanding delete all previos instalation of python, mingw64, xgboost :), but you know, it is up to you

1] install git for win (with git bash)
2] install python (I used anaconda, 3.5.1, 64bit - recommanding)
3] as admin update anaconda:
$ conda update conda
$ conda update scikit-learn (not necessary, but I used it next to xgboost)
4] download this as only this version of mingw :) - this is crucial part..
http://sourceforge.net/projects/mingw-w64/files/Toolchains%20targetting%20Win64/Personal%20Builds/mingw-builds/4.9.1/threads-posix/seh/x86_64-4.9.1-release-posix-seh-rt_v3-rev2.7z

  • do not ask why, it just works :)

5] extract to: c://mingw64//
6] in c://mingw64//bin// locate "mingw32-make.exe" and rename to "make.exe"
7] add this "c://mingw64//bin//" to enviroment PATH
8] restart PC
9] open git bash as admin

10] and now xgboost:

$ git clone --recursive https://github.com/dmlc/xgboost
$ cd xgboost
$ git submodule init
$ git submodule update
$ cd dmlc-core
$ make -j4
$ cd ../rabit
$ make lib/librabit_empty.a -j4
$ cd ..
$ cp make/mingw64.mk config.mk
$ make -j4

11] for python module
cd python-package
python setup.py install

12] launch python and enjoy :)
import xgboost
..

hi,all, i try all the way as you gived, but fail for same error
dmlc-core/include/dmlc/omp.h:9:17: fatal error: omp.h: No such file or directory
however, this omp.h file is existed in fact, open the omp.h and in line7, #include, i do't know why omp.h will include omp.h in some condition...

This means your mingw do now have openmp support.., try to find one with openmp support

@gugatr0n1c @thusithaC very thanks for your help~ i del mingw64 from my machine path, and add a new mingw64 from this instruction~then, compile successfully!!!
https://www.ibm.com/developerworks/community/blogs/jfp/entry/Installing_XGBoost_For_Anaconda_on_Windows?lang=en

I tried the methods mentioned above, but always got the following errors after I run 'make -j4'. Could anybody give me some help? Thank you!!

g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclud e -Idmlc-core/include -Irabit/include -fopenmp -c src/tree/updater_skmaker.cc -o build/tree/updater_skmaker.o
g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fopenmp -MM -MT build/tree/updater_sync.o src/tree/updater_sync.cc >build/tree/updater_sync.d
g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclud e -Idmlc-core/include -Irabit/include -fopenmp -c src/tree/updater_sync.cc -o build/tree/updater_sync.o
g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fopenmp -MM -MT build/tree/updater_refresh .o src/tree/updater_refresh.cc >build/tree/updater_refresh.d
g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclud e -Idmlc-core/include -Irabit/include -fopenmp -c src/tree/updater_refresh.cc -o build/tree/updater_refresh.o
g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fopenmp -MM -MT build/tree/updater_histmak er.o src/tree/updater_histmaker.cc >build/tree/updater_histmaker.d
g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclud e -Idmlc-core/include -Irabit/include -fopenmp -c src/tree/updater_histmaker.c c -o build/tree/updater_histmaker.o
g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fopenmp -MM -MT build/tree/tree_updater.o src/tree/tree_updater.cc >build/tree/tree_updater.d
g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclud e -Idmlc-core/include -Irabit/include -fopenmp -c src/tree/tree_updater.cc -o build/tree/tree_updater.o
g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclude -Idmlc-core/include -Irabit/include -fopenmp -MM -MT build/tree/updater_prune.o src/tree/updater_prune.cc >build/tree/updater_prune.d
g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops -Iinclud e -Idmlc-core/include -Irabit/include -fopenmp -c src/tree/updater_prune.cc -o build/tree/updater_prune.o
cd dmlc-core; C:/Users/Chang Yen-hsiu/x86_64-4.9.1-release-posix-seh-rt_v3-rev2/ mingw64/bin/mingw32-make libdmlc.a config=C:/Users/Chang Yen-hsiu/xgboost/make/c onfig.mk; cd _C:/Users/Chang Yen-hsiu/xgboost
/usr/bin/sh: C:/Users/Chang: No such file or directory
/usr/bin/sh: line 0: cd: C:/Users/Chang: No such file or directory
makefile:82: recipe for target 'dmlc-core/libdmlc.a' failed
mingw32-make: *_* [dmlc-core/libdmlc.a] Error 1
mingw32-make: *
* Waiting for unfinished jobs....

**

It's a problem with spaces in the path. Put _everything_ in paths without
spaces.
On Apr 3, 2016 2:07 PM, "derek1032" [email protected] wrote:

I tried the methods mentioned above, but always got the following errors.
Could anybody give me some help? Thank you!!

g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops
-Iinclud e -Idmlc-core/include -Irabit/include -fopenmp -c
src/tree/updater_skmaker.cc -o build/tree/updater_skmaker.o
g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops
-Iinclude -Idmlc-core/include -Irabit/include -fopenmp -MM -MT
build/tree/updater_sync.o src/tree/updater_sync.cc

build/tree/updater_sync.d
g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops
-Iinclud e -Idmlc-core/include -Irabit/include -fopenmp -c
src/tree/updater_sync.cc -o build/tree/updater_sync.o
g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops
-Iinclude -Idmlc-core/include -Irabit/include -fopenmp -MM -MT
build/tree/updater_refresh .o src/tree/updater_refresh.cc
build/tree/updater_refresh.d
g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops
-Iinclud e -Idmlc-core/include -Irabit/include -fopenmp -c
src/tree/updater_refresh.cc -o build/tree/updater_refresh.o
g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops
-Iinclude -Idmlc-core/include -Irabit/include -fopenmp -MM -MT
build/tree/updater_histmak er.o src/tree/updater_histmaker.cc
build/tree/updater_histmaker.d
g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops
-Iinclud e -Idmlc-core/include -Irabit/include -fopenmp -c
src/tree/updater_histmaker.c c -o build/tree/updater_histmaker.o
g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops
-Iinclude -Idmlc-core/include -Irabit/include -fopenmp -MM -MT
build/tree/tree_updater.o src/tree/tree_updater.cc
build/tree/tree_updater.d
g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops
-Iinclud e -Idmlc-core/include -Irabit/include -fopenmp -c
src/tree/tree_updater.cc -o build/tree/tree_updater.o
g++ -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops
-Iinclude -Idmlc-core/include -Irabit/include -fopenmp -MM -MT
build/tree/updater_prune.o src/tree/updater_prune.cc
build/tree/updater_prune.d
g++ -c -std=c++0x -Wall -O3 -msse2 -Wno-unknown-pragmas -funroll-loops
-Iinclud e -Idmlc-core/include -Irabit/include -fopenmp -c
src/tree/updater_prune.cc -o build/tree/updater_prune.o
cd dmlc-core; C:/Users/Chang
Yen-hsiu/x86_64-4.9.1-release-posix-seh-rt_v3-rev2/
mingw64/bin/mingw32-make libdmlc.a config=C:/Users/Chang
Yen-hsiu/xgboost/make/c onfig.mk; cd *

_C:/Users/Chang Yen-hsiu/xgboost /usr/bin/sh: C:/Users/Chang: No such file
or directory /usr/bin/sh: line 0: cd: C:/Users/Chang: No such file or
directory makefile:82: recipe for target 'dmlc-core/libdmlc.a' failed
mingw32-make: _* [dmlc-core/libdmlc.a] Error 1
mingw32-make: *
* Waiting for unfinished jobs....

**

—
You are receiving this because you were mentioned.
Reply to this email directly or view it on GitHub
https://github.com/dmlc/xgboost/issues/1063#issuecomment-204881734

Thank you so much for your help!!!! I can use xgboost now! @thusithaC

It might sound dumb.
Why do we need to build the wrapper dll etc on our own? Can't we just share which we have already made?

MSVC is added in #1327

I have a ploblem with a command make -j4-. This is the same ploblem, like a derek1032.
When i input make-j4-, it writes: command not found. Help me, please. I can't install xgboost due to this ploblem.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

pplonski picture pplonski  Â·  3Comments

nnorton24 picture nnorton24  Â·  3Comments

uasthana15 picture uasthana15  Â·  4Comments

wenbo5565 picture wenbo5565  Â·  3Comments

tqchen picture tqchen  Â·  4Comments