0

Installing the R package jpeg fails on a CentOS server for which I have no sudo access.

I'm using R 3.6.3. I've compiled libjpeg-turbo 1.5.2 and added the appropriate paths to PATH and LD_LIBRARY_PATH and put jpeglib.h and the other files from libjpeg-turbo-1.5.2_build/include in this directory: /home/msimenc/software/R-3.6.3_build/lib64/R/include.

I don't know how gcc can come to know what -ljpeg is. Can someone point me in the right direction?

Below is the output from install.packages("jpeg")

trying URL 'https://cloud.r-project.org/src/contrib/jpeg_0.1-8.1.tar.gz'
Content type 'application/x-gzip' length 18116 bytes (17 KB)
==================================================
downloaded 17 KB

* installing *source* package ‘jpeg’ ...
** package ‘jpeg’ successfully unpacked and MD5 sums checked
** using staged installation
** libs
gcc -std=gnu99 -I"/home/msimenc/software/R-3.6.3_build/lib64/R/include" -DNDEBUG   -I/usr/local/include  -fpic  -g -O2  -c read.c -o read.o
gcc -std=gnu99 -I"/home/msimenc/software/R-3.6.3_build/lib64/R/include" -DNDEBUG   -I/usr/local/include  -fpic  -g -O2  -c write.c -o write.o
gcc -std=gnu99 -shared -L/usr/local/lib64 -o jpeg.so read.o write.o -ljpeg
/usr/bin/ld: cannot find -ljpeg
collect2: error: ld returned 1 exit status
make: *** [jpeg.so] Error 1
ERROR: compilation failed for package ‘jpeg’
* removing ‘/home/msimenc/software/R-3.6.3_build/lib64/R/library/jpeg’

The downloaded source packages are in
    ‘/tmp/RtmpwM8sVp/downloaded_packages’
Updating HTML index of packages in '.Library'
Making 'packages.html' ... done
Warning message:
In install.packages("jpeg") :
  installation of package ‘jpeg’ had non-zero exit status
matt
  • 318
  • 3
  • 11
  • have you installed libjpeg-dev ? – Santiago I. Hurtado Apr 06 '20 at 18:54
  • 1
    @SantiagoI.Hurtado, doesn't the statement *"for which I have no sudo access"* suggest that they are unable to install it themselves? – r2evans Apr 06 '20 at 19:05
  • 1
    @matt, (1) urge your administrators to install `libjpeg-dev` (or whatever the package name is ... I'm on ubuntu), as that is the best solution; lacking that, (2) you'll need to find the source of the `libjpeg` package (this is linux, not R) and compile it yourself, then install it to a location where you have perms (perhaps somewhere in your `~`), then figure out how to add your location of header files (necessary!) to the list of possibles for the underlying makefile, as well as add this home-libpath to `LD_LIBRARY_PATH`. Or ask your admins, it really is much easier. – r2evans Apr 06 '20 at 19:07
  • @r2evans I tried to take your approach 2 but still run into the -ljpeg problem. I built libjpeg-turbo but I found no source for libjpeg-dev – matt Apr 06 '20 at 19:47
  • `libjpeg-dev` is just a portion of the complete compiled package. Typically, the main package (e.g., `libjpeg`) has just the dll/shared-object, but no headers or static libraries. The dev package (e.g., `libjpeg-dev`) has header files (`*.h`) and static libraries (e.g., `*.a`) and other things. When you compile from source, you have all of that in one place, so there isn't a `libjpeg-dev` source tarball. Most other packages that depend on `libjpeg` only need the shared objects, not the headers/statics, so a normal practice it to no install dev stuff until needed. – r2evans Apr 06 '20 at 21:08
  • @r2evans libjpeg-turbo has header files and static libraries and I've added their location to LD_LIBRARY_PATH. However, I'm not sure how to add the location of header files to the list of possibles for the makefile because the build is handled through R and I don't have access to a makefile. – matt Apr 07 '20 at 00:35
  • 1
    That's where the pain of this really pans out ... I don't have the best answer for you, I haven't done it, and I was really hoping you would be able to go down path number one. – r2evans Apr 07 '20 at 03:41

0 Answers0