在 windows7, python2.7 安装 xgboost4.0 时发生错误

error happens when install xgboost4.0 in windows7, python2.7

这是我尝试安装 xgboost 的过程:

git clone --recursive https://github.com/dmlc/xgboost
git submodule init
git submodule update
cp make/mingw64.mk config.mk

在我 运行 我的 git bash

中的代码之前一直很好
 make -j4

出错了:

    F:/mingw64/x86_64-w64-mingw32/include/stdio.h:450:83: error: 'FILE* std::fopen(const char*, const char*)' should have been declared inside 'std'
   FILE *fopen64(const char * __restrict__ filename,const char * __restrict__  mode);
                                                                                   ^
F:/mingw64/x86_64-w64-mingw32/include/stdio.h:450:83: error: 'FILE* std::fopen(const char*, const char*)' conflicts with a previous declaration
F:/mingw64/x86_64-w64-mingw32/include/stdio.h:449:17: note: previous declaration 'FILE* fopen(const char*, const char*)'
   FILE *__cdecl fopen(const char * __restrict__ _Filename,const char * __restrict__ _Mode) __MINGW_ATTRIB_DEPRECATED_SEC_WARN;
                 ^
Makefile:97: recipe for target 'build/c_api/c_api_error.o' failed
make: *** [build/c_api/c_api_error.o] Error 1
make: *** Waiting for unfinished jobs....
In file included from dmlc-core/include/dmlc/registry.h:14:0,
                 from include/xgboost/./gbm.h:11,
                 from include/xgboost/learner.h:16,
                 from src/learner.cc:8:
dmlc-core/include/dmlc/./parameter.h:254:43: warning: 'xgboost::__make__LearnerModelParamParamManager__' defined but not used [-Wunused-variable]
   static ::dmlc::parameter::ParamManager &__make__ ## PType ## ParamManager__ = \
                                           ^
src/learner.cc:107:1: note: in expansion of macro 'DMLC_REGISTER_PARAMETER'
 DMLC_REGISTER_PARAMETER(LearnerModelParam);
 ^
dmlc-core/include/dmlc/./parameter.h:254:43: warning: 'xgboost::__make__LearnerTrainParamParamManager__' defined but not used [-Wunused-variable]
   static ::dmlc::parameter::ParamManager &__make__ ## PType ## ParamManager__ = \
                                           ^
src/learner.cc:108:1: note: in expansion of macro 'DMLC_REGISTER_PARAMETER'
 DMLC_REGISTER_PARAMETER(LearnerTrainParam);

我找到了一些参考,说明原因可能与 windows 系统和 Unix 之间的差异有关,但这超出了我的知识范围。

我安装了mingw64

github page 上提出了一个问题。

克隆后,检查版本 9a48a40,然后重复您在上面执行的步骤。我遇到了同样的问题,这对我有用。

引用自link:

Fixed, just clone repo and then checkout to 9a48a40 until they fix it, something in the last commits must have screwed up the compilation:

git clone --recursive https://github.com/dmlc/xgboost
cd xgboost
git checkout 9a48a40
git submodule init
git submodule update