I’m trying to install jpeg
package in R in a Linux server (in which I don’t have sudo access) and jpeg
installation does not find jpeglib.h
I installed locally. How do I tell R where to look for it when configure.args='--with-libjpeg-include=/path
failed?
Sever OS version is CentOS Linux 7 (Core)
In R I ran:
>install.packages('jpeg', lib="/shared/mybossusr/R3.5.0/lib", repos="https://mirrors.nic.cz/R/", destdir="/shared/mybossusr/usr/tmp")
And I got this error:
rjcommon.h:11:21: fatal error: jpeglib.h: No such file or directory
#include
So I installed jpeg-turbo
wget https://downloads.sourceforge.net/libjpeg-turbo/libjpeg-turbo-2.0.2.tar.gz
mkdir libjpeg-turbo-2
cd libjpeg-turbo-2
cmake -G"Unix Makefiles" -DCMAKE_INSTALL_PREFIX:PATH=/shared/mybossusr/bin/libjpeg-turbo-2 /shared/mybossusr/download/libjpeg-turbo-2.0.2
make
make install
I checked and jpeglib.h
is at /shared/mybossusr/bin/libjpeg-turbo-2/include
I added this at the end of my ~/.bashrc
:
export CFLAGS="-I/usr/include -I=/shared/mybossusr/bin/libjpeg-turbo-2"
I logged out and in, and I got the same error when trying to install jpeg
in R.
I also added the location of the library to my path at ~/.barsh
:
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/shared/mybossusr/bin/libjpeg-turbo-2/include
export PATH=$PATH:/shared/mybossusr/bin/libjpeg-turbo-2/include
just in case, because I don’t fully understand when a software looks where. Did source ~/.bashrc
, logged out and in, but nothing changed.
So, I tried afterwards in R some arguments I came up with:
install.packages('jpeg', lib="/shared/mybossusr/R3.5.0/lib", repos="https://mirrors.nic.cz/R/", destdir="/shared/mybossusr/R3.5.0/tmp", configure.args='--with-libjpeg-include=/shared/mybossuser/bin/jpeg/include')
and:
install.packages('jpeg', lib="/shared/mybossusr/R3.5.0/lib", repos="https://mirrors.nic.cz/R/", destdir="/shared/mybossusr/R3.5.0/tmp", configure.args='--with-libjpeg=/shared/mybossuser/bin/jpeg')
or:
install.packages('jpeg', lib="/shared/mybossusr/R3.5.0/lib", repos="https://mirrors.nic.cz/R/", destdir="/shared/mybossusr/R3.5.0/tmp", configure.args='--with-libjpeg-lib=/shared/mybossuser/bin/jpeg/include')
to try to tell R where libjpeg
was installed, but nothing worked.
Is there any configure.args
that will do the trick? So far with other packages it was quite straight forward to use a --with-package_name-lib
, but I’m clueless with this one…
Thanks in advance!
3
Answers
Try installing the
libjpeg-turbo-devel
package. That’s what did it for me on RHEL 7. According to this page, on CentOS 7 the package name is the same.For me this is what did the trick:
Install jpeg-turbo in a non-standard location, say
$HOME/local
, from:https://github.com/libjpeg-turbo/libjpeg-turbo/releases
Then point these globals to the install location in your
.bashrc
:Then try the R package again
I had the same issue with the config.args in the
install.packages()
command in R – for some reason--with-libjpeg-include
doesn’t point the compiler to the non-standard location I speficied. So here’s how I worked around it.First, I installed
libjpeg
(link) in a non-standard location.Then, I added the path to my libjpeg to LD_LIBRARY_PATH.
Then, in R, I told the c compiler (in my case gcc) where to look when compiling files. Normally, we shouldn’t do this, but we are only doing this because configure.args doesn’t work.
Finally, I installed the r package
jpeg
. There is no need to add config.args because they didn’t work anyway.