安装xgboost出现的bug记录

Building on OSX

根据官网的说法,安装非常简单
brew install gcc@8
pip3 install xgboost
但是---

/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/Availability.h:257:22: error: missing binary operator before token "("
         #if __has_builtin(__is_target_arch)

在使用pip3安装时报错(居然还是来自xcode源码的错误……我服了

根据homebrew上的说法

This is a bug in the C library that comes with the updated Xcode. To fix it, edit the file /Library/Developer/CommandLineTools/SDKs/MacOSX10.14.sdk/usr/include/Availability.h (must be done as root). Near the point where the error is generated (line number 257), add the following two lines:

Xcode更新的源码里有bug……
需要修改:在/Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/Availability.h中添加两行

#elif defined(__MAC_OS_X_VERSION_MIN_REQUIRED)
  #if defined(__has_builtin)   // <=== ADD THIS LINE
    #if __has_builtin(__is_target_arch)
     #if __has_builtin(__is_target_vendor)
      #if __has_builtin(__is_target_os)
       #if __has_builtin(__is_target_environment)
        #if __has_builtin(__is_target_variant_os)
         #if __has_builtin(__is_target_variant_environment)
          #if (__is_target_arch(x86_64) && __is_target_vendor(apple) && ((__is_target_os(ios) && __is_target_environment(macabi)) || (__is_target_variant_os(ios) && __is_target_variant_environment(macabi))))
            #define __OSX_AVAILABLE_STARTING(_osx, _ios) __AVAILABILITY_INTERNAL##_osx __AVAILABILITY_INTERNAL##_ios
            #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) \
                                                            __AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep __AVAILABILITY_INTERNAL##_iosIntro##_DEP##_iosDep
            #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) \
                                                            __AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep##_MSG(_msg) __AVAILABILITY_INTERNAL##_iosIntro##_DEP##_iosDep##_MSG(_msg)
          #endif /* # if __is_target_arch... */
         #endif /* #if __has_builtin(__is_target_variant_environment) */
        #endif /* #if __has_builtin(__is_target_variant_os) */
       #endif /* #if __has_builtin(__is_target_environment) */
      #endif /* #if __has_builtin(__is_target_os) */
     #endif /* #if __has_builtin(__is_target_vendor) */
    #endif /* #if __has_builtin(__is_target_arch) */
  #endif   // <=== ADD THIS LINE

    #ifndef __OSX_AVAILABLE_STARTING
        #define __OSX_AVAILABLE_STARTING(_osx, _ios) __AVAILABILITY_INTERNAL##_osx
        #define __OSX_AVAILABLE_BUT_DEPRECATED(_osxIntro, _osxDep, _iosIntro, _iosDep) \
                                                        __AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep
        #define __OSX_AVAILABLE_BUT_DEPRECATED_MSG(_osxIntro, _osxDep, _iosIntro, _iosDep, _msg) \
                                                        __AVAILABILITY_INTERNAL##_osxIntro##_DEP##_osxDep##_MSG(_msg)
    #endif /* __OSX_AVAILABLE_STARTING */

#else

修改完后就成功安装了,还真是这个bug,我服了……

参考

Installation Guide
Upgrading to Xcode CLT 11.0 broke GCC 9

你可能感兴趣的:(安装xgboost出现的bug记录)