I am trying to install sparkTable
in R 3.1.0 which depends on Rglpk
. I manually installed GPLK on the system and added the libs folder to LD_LIBRARY_PATH
before going into R for the install.packages("sparkTable")
procedure. I get this error during the installation process. Any ideas?
* installing *source* package ‘Rglpk’ ...
** package ‘Rglpk’ successfully unpacked and MD5 sums checked
** libs
/bin/sh: line 0: cd: GLPK: No such file or directory
make: *** [GLPK.ts] Error 1
ERROR: compilation failed for package ‘Rglpk’
* removing ‘/opt/R/R-3.1.0/lib64/R/library/Rglpk’
ERROR: dependency ‘Rglpk’ is not available for package ‘sparkTable’
* removing ‘/opt/R/R-3.1.0/lib64/R/library/sparkTable’
sudo apt-get install libglpk-dev
did the trick for me.
I had this problem and took a good bit of digging in the package to understand what was happening. If Rgplk can't compile its test program when installing, it does something weird, including this bizarre cd to nowhere. Assuming glpk-devel is installed, the reason it can't compile the test program is that it can't find the gplk header as it is in a non-standard directory.
Just set the environment variable CPATH=/usr/include/glpk
and the test program will compile, allowing the package install to proceed normally.
I had this problem too. The following steps solved this issue for me. My current setup:
- OS: Scientifc Linux version 6.5 (on a High Performance Cluster Server)
- local user, no root access.
- GLPK was not installed
Install GLPK in a local directory:
wget http://ftp.gnu.org/gnu/glpk/glpk-4.54.tar.gz
tar xfzv glpk-4.54.tar.gz
mkdir GLPK
cd glpk-4.54
./configure --prefix=/home/<username>/GLPK
make
make install
Install Rglpk (0.6-3):
cd ~
wget http://cran.r-project.org/src/contrib/Rglpk_0.6-3.tar.gz
export LIBRARY_PATH=/home/<username>/GLPK/lib
R CMD INSTALL Rglpk_0.6-3.tar.gz
On Centos, have sudo rights. None of the above worked, but had to install GLPK in /usr/local as suggested in this SO answer. Been trying to install it for about 3 hours fml
In ubuntu 14.04, all above doesn't work. the following however works, without the need of installing libglpk-dev using apt-get.
download the glpk package from gnu and extract it:
wget http://ftp.gnu.org/gnu/glpk/glpk-4.55.tar.gz
tar xvf glpk-4.55.tar.gz
make a GLPK directory in your local path:
mkdir ~/GLPK
configure within glpk:
cd glpk-4.55
./configure --prefix=$HOME/GLPK
cd ..
export LD_LIBRARY_PATH=$HOME/GLPK/lib
export LIBRARY_PATH=$HOME/GLPK/lib
export CPATH=$HOME/GLPK/include
download the Rglpk package from cran and extract it:
wget http://cran.r-project.org/src/contrib/Rglpk_0.6-0.tar.gz
tar xvf Rglpk_0.6_0.tar.gz
move the glpk directory into Rglpk/src and rename it to GLPK:
mv glpk-4.55 Rglpk/src/GLPK
now you can install:
R CMD INSTALL Rglpk
now a bit of explanation of what's going on. The "src/Makevars.in" file in the Rglpk package contains a line of code to enter a non-existing directory 'GLPK' within the src/ folder:
(line 11 of Makevars.in)
GLPK.ts:
@(cd GLPK && make)
touch $@
this is where the problem arises. obviously the code is trying to build glpk within that directory for some unknown reasons. and the solution above is achieved simply by moving the downloaded (and configured) glpk directory there...
You must install glpk
dependency first.
On macOS (via homebrew):
brew install glpk
or in RStudio (via homebrew):
system("brew install glpk")