GLPK: No such file or directory error when trying to install R package

流过昼夜 提交于 2019-11-29 06:53:25
sudo apt-get install libglpk-dev

did the trick for me.

frankc

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.

Thomas

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
dtjones

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")
标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!