LightGBM: Install R package error ( Windows10 )

Environment info

Windows 10 x64 R version 3.5.1(Path) Rtools34 (Path) VS 2017 Cmake(Path)

Running following command in RStudio

devtools::install_github("Laurae2/lgbdl", force = TRUE)
library(lgbdl)
lgb.dl(commit = "master",
compiler = "vs",
repo = "https://github.com/Microsoft/LightGBM",
cores =6,
r35 = true)

Error message

* installing *source* package 'lightgbm' ...
** libs
c:/Rtools/mingw_64/bin/gcc  -I"C:/R/R-35~1.1/include" -DNDEBUG          -O2 -Wall  -std=gnu99 -mtune=generic -c R_init.c -o R_init.o
c:/Rtools/mingw_64/bin/gcc -shared -s -static-libgcc -o lightgbm.dll tmp.def R_init.o -LC:/R/R-35~1.1/bin/x64 -lR
installing via 'install.libs.R' to C:/R/R-3.5.1/library/lightgbm
 eval(ei, envir) error : Copying CMakeLists failed
* removing 'C:/R/R-3.5.1/library/lightgbm'
In R CMD INSTALL
[1] FALSE
Warning message:
In install.packages(file.path(lgb_git_dir, "LightGBM", "R-package",  :
  installation of package ‘C:/Users/Kline/AppData/Local/Temp/Rtmpwb0XlY/LightGBM/R-package’ had non-zero exit status

I found the error message “Copying CMakeLists failed” in the following URL (line 20), but I don’t know how to fix it. Please help me. https://github.com/Microsoft/LightGBM/blob/master/R-package/src/install.libs.R

# Move in CMakeLists.txt
if (!file.copy("../inst/bin/CMakeLists.txt", "CMakeLists.txt", overwrite = TRUE)){
  stop("Copying CMakeLists failed")
}

About this issue

  • Original URL
  • State: closed
  • Created 6 years ago
  • Comments: 19 (3 by maintainers)

Most upvoted comments

When I attempt to install the R package on Windows with the precompiled dll, even after following the install instructions and copying the .dll, I get

Error in eval(ei, envir) : Cannot find lib_lightgbm.dll

This is unusual. Followed all the install instructions and the instructions in this comment, and even tried putting the .dll all over the place. But it still couldn’t be found.

It is the same as spedygiorgio’s issue.

hey guys i just installed lightgbm package these are the steps to reproduce :

1 - git clone --recursive https://github.com/Microsoft/LightGBM 2 - cd LightGBM 3 - open R-package/src/install.lib and change use_precompile from FALSE to TRUE 4 - go to root directory of lightgbm and copy cmakelists and paste it to R-package/inst/bin 5 - cd lightGBM 6 - Rscript build_r.R 7 - cd r_lightgbm 8 - R CMD INSTALL --build . --no-multiarch

@Kallikrates
make sure you have mingw32-make.exe in your PATH.

$ mingw32-make.exe --version
GNU Make 4.1
Built for x86_64-w64-mingw32
Copyright (C) 1988-2014 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
  1. add C:\Rtools\bin; to your system PATH, close terminal and reopen try again;
  2. reinstall CMake to C:\ProgramFiles\CMake (without space in the path) and add it to the PATH variable, close and reopen , try again;

@teru111 pleage see : https://github.com/Laurae2/lgbdl/issues/4

you’d better use Rtools35, if you use gcc compiler

create a temp.bat with the following codes if you use vs compiler :

C:
cd C:\
git clone --recursive https://github.com/Microsoft/LightGBM
cd LightGBM
git checkout master
mkdir build && cd build
cmake -DCMAKE_GENERATOR_PLATFORM=x64 -DUSE_R35=1  ..
cmake --build . --target _lightgbm  --config Release

run the temp.bat

gcc compiler :

c:
cd C:\
git clone --recursive https://github.com/Microsoft/LightGBM
cd LightGBM
git checkout master
mkdir build && cd build
cmake -G "MinGW Makefiles" -DUSE_R35=1  ..
cmake -G "MinGW Makefiles" -DUSE_R35=1  ..
mingw32-make.exe -j1
  1. open the C:\LightGBM\R-package\src\install.libs.R
  2. set use_precompile <- TRUE
  3. modify if (!file.copy("../../CMakeLists.txt", "../CMakeLists.txt", overwrite = TRUE)){ stop("Copying CMakeLists failed") }
  4. Rscript> install.packages(file.path("C:", "LightGBM", "R-package", fsep = "\\"), repos = NULL, type = "source")
  5. done!

the gcc compiler can be reproducible and tested in my Windows computer