0

我尝试在 Mac 上使用 devtools 安装 R 包“lightgbm”(High Sierra 10.13.5;R 版本 3.5.0;devtools 1.13.5)。

但是发生了错误,并显示了以下消息。

> library(devtools)
> install_github("Microsoft/LightGBM", subdir = "R-package")
Downloading GitHub repo Microsoft/LightGBM@master
from URL https://api.github.com/repos/Microsoft/LightGBM/zipball/master
Installing lightgbm
'/Library/Frameworks/R.framework/Resources/bin/R' --no-site-file --no-environ --no-save  \
  --no-restore --quiet CMD INSTALL  \
  '/private/var/folders/5n/8jscplj12gg0b6_p9h_rqcmc0000gn/T/RtmpNnPRWk/devtools35b1eee5504/Microsoft-LightGBM-c0147cb/R-package'  \
  --library='/Library/Frameworks/R.framework/Versions/3.5/Resources/library' --install-tests 

* installing *source* package ‘lightgbm’ ...
** libs
installing via 'install.libs.R' to /Library/Frameworks/R.framework/Versions/3.5/Resources/library/lightgbm
-- The C compiler identification is AppleClang 9.1.0.9020039
-- The CXX compiler identification is AppleClang 9.1.0.9020039
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc
-- Check for working C compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/cc -- works
-- Detecting C compiler ABI info
-- Detecting C compiler ABI info - done
-- Detecting C compile features
-- Detecting C compile features - done
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++
-- Check for working CXX compiler: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/c++ -- works
-- Detecting CXX compiler ABI info
-- Detecting CXX compiler ABI info - done
-- Detecting CXX compile features
-- Detecting CXX compile features - done
CMake Error at CMakeLists.txt:27 (message):
  AppleClang isn't supported.  Please see
  https://github.com/Microsoft/LightGBM/blob/master/docs/Installation-Guide.rst#macos


-- Configuring incomplete, errors occurred!
See also "/private/var/folders/5n/8jscplj12gg0b6_p9h_rqcmc0000gn/T/RtmpNnPRWk/devtools35b1eee5504/Microsoft-LightGBM-c0147cb/R-package/src/build/CMakeFiles/CMakeOutput.log".
make: *** No rule to make target `_lightgbm'.  Stop.
Error in eval(ei, envir) : Cannot find lib_lightgbm.so
* removing ‘/Library/Frameworks/R.framework/Versions/3.5/Resources/library/lightgbm’
Installation failed: Command failed (1)
Warning message:
GitHub repo contains submodules, may not function as expected! 

所以我想使用 gcc(我通过自制软件安装它)而不是 AppleClang。

我该怎么做?

谢谢

4

1 回答 1

0

我采取的完整步骤。用自制软件更新了 gcc。可能没有必要——它让我使用了 gcc-8。

我没有跟踪我找到的解决方法的所有链接,所以只是给出了步骤。

git clone --recursive https://github.com/Microsoft/LightGBM ; cd LightGBM

mkdir build ; cd build

cmake -DCMAKE_C_COMPILER=gcc-8 -DCMAKE_CXX_COMPILER=g++-8 ..

export PATH=/usr/bin:$PATH

make -j4

这构建了它,但它似乎不适合 R。所以......

cd ..

cd R-package

R CMD INSTALL --build . --no-multiarch

似乎记住了先前的设置,并再次为 R 成功构建了它。至少“库(lightgbm)”有效。这就是我所得到的。

于 2018-06-23T23:07:59.160 回答