Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

Tags:

r

glpk

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’
like image 792
719016 Avatar asked Aug 04 '14 08:08

719016


4 Answers

I landed on this page, because I could not update igraph under Windows 10/11, since igraph also requires glpk as per OP. Specifically:

igraph_glpk_support.h:36:10: fatal error: glpk.h: No such file or directory #include <glpk.h> ^~~~~~~~ compilation terminated. make: *** [C:/PROGRA~1/R/R-4.1.1/etc/x64/Makeconf:238: feedback_arc_set.o] Error 1 ERROR: compilation failed for package 'igraph'

  • removing 'C:/Users/xxx/Documents/R/win-library/4.1/igraph'
  • restoring previous 'C:/Users/xxx/Documents/R/win-library/4.1/igraph' Warning in install.packages : installation of package ‘igraph’ had non-zero exit status

I am under Windows 11 (but would be same for Windows 10). Simple resolution is suggested here:

  1. start Rtools Bash (found in all apps, Rtools 4.0 in the Windows menu)
  2. Run pacman -S mingw-w64-x86_64-glpk and confirm with yes (y)
  3. Run pacman -S mingw-w64-x86_64-libxml2 and confirm with yes (y)
  4. Updating igraph in Rstudio now leads to a clean

DONE (igraph)

(there is no need to install anything, add any path, etc... just the above 4 steps)

like image 85
tchevrier Avatar answered Sep 30 '22 18:09

tchevrier


sudo apt-get install libglpk-dev

did the trick for me.

like image 36
hanshansen Avatar answered Nov 05 '22 13:11

hanshansen


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.

like image 9
frankc Avatar answered Nov 05 '22 11:11

frankc


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
like image 9
Thomas Avatar answered Nov 05 '22 13:11

Thomas