Building R-devel on RedHat Linux 6

 

Warning: I'm 85% done with this, formatting is not right. I DO NOT want to type in the prompt in front of every command because then one cannot copy/paste directly.  However, copying some output chunks picks up the dollar signs and I'm inconsistent.

Brief Summary: R-devel will not build without access to newer zlib, bzip2.  This is a problem because CRAN requires users to test packages against R-devel, not against existing R or R-patched. This note has step-by-step information about what was necessary to compile & install R-devel in my user account on a cluster compute environment running RedHat 6 Linux.To upload an R package, one must agree to compile the package against R-devel, the cutting edge version of R.

The 2016 current version of R-devel has removed the versions of several compression libraries that used to be included. Instead of providing those libraries, R-devel supposes they are installed in the operating system. On my up-to-date Ubuntu laptop, this was not a concern because I have up-to-date versions of zlib, xz, pcre, and curl.On the compute cluster, which is still running RedHat 6, it is a more serious problem because the libraries zlib, bzip, pcre, curl, and xz are out of date. We find that out because when we try to build R-devel, it fails and tells us what is out of date.

As a result, one cannot configure and compile R-devel. One must get updated libraries. If the system administrators would replace all of those libraries, we could go ahead.However, in a Unix system, it is possible to compile and install support libraries in a user's account, without system-wide intervention. With the exception of bzip2, where theinstallation is a non-standard setup, the installs of zlib, xz, curl, and pcre are standard and easy. Building R-devel on a Linux system with slightly older packges.

Here is the process I went through on RHEL6 to make this go. Special thanks to Wes Mason at KU ITTC who provided the critical ingredient.

1. Our cluster defaults to an ancient version of gcc.   I can tell my environment to use the newer gcc compiler

$ module avail
$ module load gcc/4.9.22

2. Try to build R-devel without making any special preparations.

mkdir src
 cd src
 wget --no-check-certificate https://stat.ethz.ch/R/daily/R-devel_2016-02-11.tar.gz
 tar xzvf R-devel_2016-02-11.tar.gz
 cd R-devel
 ./configure --help
mkdir builddir
 cd builddir
 ../configure --prefix=$HOME/packages/R-devel '--with-cairo' \
 '--with-jpeglib' '--with-readline' '--with-tcltk' \
 '--with-blas' '--with-lapack' '--enable-R-profiling' \
 '--enable-R-shlib' \
 '--enable-memory-profiling'
## fails ignominously:
 checking if zlib version >= 1.2.5... no
 checking whether zlib support suffices... configure: error: zlib
 library and headers are required

3. Install zlibDownload, un-tar, configure, compile

cd ~/src
 wget http://zlib.net/zlib-1.2.8.tar.gz
 tar xzvf zlib-1.2.8.tar.gz
 cd zlib-1.2.8
 ./configure --prefix=$HOME/packages

I won't show all the output for all of these things, but this is brief and representative

 Checking for gcc...
 Checking for shared library support...
 Building shared library libz.so.1.2.8 with gcc.
 Checking for off64_t... Yes.
 Checking for fseeko... Yes.
 Checking for strerror... Yes.
 Checking for unistd.h... Yes.
 Checking for stdarg.h... Yes.
 Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf().
 Checking for vsnprintf() in stdio.h... Yes.
 Checking for return value of vsnprintf()... Yes.
 Checking for attribute(visibility) support... Yes.

This is the common GNU-style software. configure. make. make install. Run those:

make
make install
$ make install
 cp libz.a /home/pauljohn/packages/lib
 chmod 644 /home/pauljohn/packages/lib/libz.a
 cp libz.so.1.2.8 /home/pauljohn/packages/lib
 chmod 755 /home/pauljohn/packages/lib/libz.so.1.2.8
 cp zlib.3 /home/pauljohn/packages/share/man/man3
 chmod 644 /home/pauljohn/packages/share/man/man3/zlib.3
 cp zlib.pc /home/pauljohn/packages/lib/pkgconfig
 chmod 644 /home/pauljohn/packages/lib/pkgconfig/zlib.pc
 cp zlib.h zconf.h /home/pauljohn/packages/include
 chmod 644 /home/pauljohn/packages/include/zlib.h /home/pauljohn/packages/include/zconf.h

4. Adjust the environment so R-devel builds will find packages installed there.

 export PATH=$HOME/packages/bin:$PATH
 export LD_LIBRARY_PATH=$HOME/packages/lib:$LD_LIBRARY_PATH 
 export CFLAGS="-I$HOME/packages/include" 
 export LDFLAGS="-L$HOME/packages/lib" 
The first two are vital during the "make" phase in R-devel, the latter 2 are vital in the "configure" phase in R-devel.5. Try to build R-devel again, using new zlibI remove and remake the build directory, so that any accumulated errors are eliminated
cd ~/src
cd R-devel/
rm -rf builddir
mkdir builddir
cd builddir/
../configure --prefix=$HOME/packages/R-devel --with-cairo \
 --with-jpeglib --with-readline --with-tcltk \
 --with-blas --enable-BLAS-shlib --with-lapack --enable-R-profiling \
 '--enable-R-shlib' \
 '--enable-memory-profiling'

That succeeds, finds zlib, but configure ends with this error:

checking bzlib.h presence... yes
 checking for bzlib.h... yes
 checking if bzip2 version >= 1.0.6... no
 checking whether bzip2 support suffices... configure: 
error: bzip2 library and headers are required

6. Get new bzlib support. This one is not built with GNU auto tools,so it is a little more interesting/idiosyncratic. Would not havesolved it without help from this site:http://www.linuxfromscratch.org/lfs/view/development/chapter06/bzip2.html

## So we go get bzlib, which is part of bzip2, just like we did on zlib

cd ~/src
wget http://www.bzip.org/1.0.6/bzip2-1.0.6.tar.gz
tar xzvf bzip2-1.0.6.tar.gz
cd bzip2-1.0.6

Inspect the README. Temptation is to be careless and just run make, but that's not quite enough because we need the shared library. Then make after

make -f Makefile-libbz2_so
 make clean
 make
 make -n install PREFIX=$HOME/packages
 make install PREFIX=$HOME/packages

7. Try to build R-devel again

cd ~/src/R-devel
 rm -rf builddir/
 mkdir builddir
 cd builddir
 ../configure --prefix=$HOME/packages/R-devel '--with-cairo' \
 '--with-jpeglib' '--with-readline' '--with-tcltk' \
 '--with-blas' '--with-lapack' '--enable-R-profiling' \
 '--enable-R-shlib' \
 '--enable-memory-profiling'

configure fails with

checking whether bzip2 support suffices... no
 checking for lzma_version_number in -llzma... no
 configure: error: "liblzma library and headers are required"

8. Go get liblzma. I tried that, couldn't compile that, but Wes Mason warned me not to try to install the separate liblzma, but rather get the package known as xz.

cd ~/src
wget http://tukaani.org/xz/xz-5.2.2.tar.gz
tar xzvf xz-5.2.2.tar.gz
cd xz-5.2.2
./configure --prefix=$HOME/packages
make -j3
make install

8.  Try R-devel again, same steps as before, make builddir, then

../configure --prefix=$HOME/packages/R-devel '--with-cairo' \
 '--with-jpeglib' '--with-readline' '--with-tcltk' \
 '--with-blas' '--with-lapack' '--enable-R-profiling' \
 '--enable-R-shlib' \
 '--enable-memory-profiling'

That gets quite a bit further and fails:

checking for pcre/pcre.h... no
 checking if PCRE version >= 8.10, < 10.0 and has UTF-8 support... no checking whether PCRE support suffices... configure: error: pcre >= 8.10 library and headers are required

9. Get pcre. This is getting old now

cd ~/src

 wget
 ftp://ftp.csx.cam.ac.uk/pub/software/programming/pcre/pcre-8.38.tar.gz

 tar xzvf pcre-8.38.tar.gz
 ./configure --prefix=$HOME/packages
 make -j3
 make install

9B. Back to R-develR-devel configure fails same way:

checking for pcre/pcre.h... no
checking if PCRE version >= 8.10, < 10.0 and has UTF-8 support...
no checking whether PCRE support suffices... 
configure: error: pcre >= 8.10 library and headers are required

9C So I suspect the UTF-8 support is the issue.Back to PCRE, reconfigure. Usually, best to erase whole sourcedirectory and get a clean run at it. Because I did not do safe thingand use a builddir in there, I have to do that. I run this configure command,

./configure --enable-utf8 --prefix=$HOME/packages
make 
make install

10. Try R-devel again.Fails asking for libcurl

 checking libcurl version ... 7.19.7
 checking curl/curl.h usability... yes
 checking curl/curl.h presence... yes
 checking for curl/curl.h... yes
 checking if libcurl is version 7 and >= 7.28.0... no
 configure: error: libcurl >= 7.28.0 library and headers are 
required with support for https

11. Install libcurl## Note need ignore certificate problem on this one

 cd ~/src
 wget --no-check-certificate https://curl.haxx.se/download/curl-7.47.1.tar.gz
 tar xzvf curl-7.47.1.tar.gz
 cd curl-7.47.1
 ./configure --prefix=$HOME/packages
 make -j3
 make install

12. Try R-devel again

cd ~/src
 cd R-devel
 rm -rf builddir
 mkdir builddir
 cd builddir
 ../configure --prefix=$HOME/packages/R-devel '--with-cairo' \
 '--with-jpeglib' '--with-readline' '--with-tcltk' \
 '--with-blas' '--with-lapack' '--enable-R-profiling' \
 '--enable-R-shlib' \
 '--enable-memory-profiling'

HOORAY, it finished!

config.status: creating tests/Embedding/Makefile
 config.status: creating tests/Examples/Makefile
 config.status: creating tools/Makefile
 config.status: creating src/include/config.h
 config.status: executing libtool commands
 config.status: executing stamp-h commands
R is now configured for x86_64-pc-linux-gnu
Source directory: ..
 Installation directory: /home/pauljohn/packages/R-devel
C compiler: gcc -std=gnu99 -I/home/pauljohn/packages/include
 Fortran 77 compiler: gfortran -g -O2
C++ compiler: g++ -g -O2
 C++11 compiler: g++ -std=c++11 -g -O2
 Fortran 90/95 compiler: gfortran -g -O2
 Obj-C compiler: gcc -g -O2 -fobjc-exceptions
Interfaces supported: X11, tcltk
 External libraries: readline, BLAS(generic), LAPACK(generic), curl
 Additional capabilities: PNG, JPEG, NLS, cairo, ICU
 Options enabled: shared R library, R profiling, memory profiling
Capabilities skipped: TIFF
 Options not enabled: shared BLAS
Recommended packages: yes
configure: WARNING: you cannot build info or HTML versions of the R manuals
configure: WARNING: neither inconsolata.sty nor zi4.sty found: PDF vignettes and package manuals will not be rendered optimally

That last warning, well, I'm ignoring it. I don't need to build their documents, I need to see if my package builds without errors. I don't care much that shared BLAS is not enabled, but I ususally would want that if I were making a production system.However, running

make

ends in failure:

gcc -std=gnu99 -shared -fopenmp -L/home/pauljohn/packages/lib -o libR.so 
CommandLineArgs.o Rdynload.o Renviron.o RNG.o agrep.o apply.o 
arithmetic.o array.o attrib.o bind.o builtin.o character.o coerce.o 
colors.o complex.o connections.o context.o cum.o dcf.o datetime.o 
debug.o deparse.o devices.o dotcode.o dounzip.o dstruct.o 
duplicate.o edit.o engine.o envir.o errors.o eval.o format.o 
gevents.o gram.o gram-ex.o graphics.o grep.o identical.o 
inlined.o inspect.o internet.o iosupport.o lapack.o list.o 
localecharset.o logic.o main.o mapply.o match.o memory.o 
names.o objects.o options.o paste.o platform.o plot.o plot3d.o 
plotmath.o print.o printarray.o printvector.o printutils.o qsort.o 
radixsort.o random.o raw.o registration.o relop.o rlocale.o 
saveload.o scan.o seq.o serialize.o sort.o source.o split.o 
sprintf.o startup.o subassign.o subscript.o subset.o summary.o 
sysutils.o times.o unique.o util.o version.o g_alab_her.o 
g_cntrlify.o g_fontdb.o g_her_glyph.o xxxpr.o `ls ../unix/*.o 
../appl/*.o ../nmath/*.o` ../extra/tre/libtre.a -lblas -lgfortran 
-lm -lquadmath -lreadline -lpcre -llzma -lbz2 -lz -lrt -ldl -lm 
-licuuc -licui18n
 /usr/bin/ld: /home/pauljohn/packages/lib/libbz2.a(bzlib.o): 
relocation R_X86_64_32S against `BZ2_crc32Table' can not be used 
when making a shared object; recompile with -fPIC
 /home/pauljohn/packages/lib/libbz2.a: could not read symbols: Bad value
 collect2: error: ld returned 1 exit status
 make[3]: *** [libR.so] Error 1
 make[3]: Leaving directory `/panfs/pfs.acf.ku.edu/home/pauljohn/src/R-devel/builddir/src/main'
 make[2]: *** [R] Error 2
 make[2]: Leaving directory `/panfs/pfs.acf.ku.edu/home/pauljohn/src/R-devel/builddir/src/main'
 make[1]: *** [R] Error 1
 make[1]: Leaving directory `/panfs/pfs.acf.ku.edu/home/pauljohn/src/R-devel/builddir/src'
 make: *** [R] Error 1

13. That's certainly pointing the finger back at bzip2, which is the only non-standard library in the whole batch. It doesn't use GNU autoconf, has vague instructions. I went into the bzip2 directory and inserted -fPIC as a CFLAG in the Makefile. Then I ran make and make install PREFIX=$HOME/packages again, as above14. R-devel, againrm the builddirmake a new builddir, go in there, run the configure statement, looksOK

make

succeeds. Be aware, it is VITAL the PATH and LD_LIBRARY_PATH be set in the environment as stated above.Here's the evidence it did eventually compile

make[2]: Leaving directory `/panfs/pfs.acf.ku.edu/home/pauljohn/src/R-devel/builddir/src/library/Recommended'
make[1]: Leaving directory `/panfs/pfs.acf.ku.edu/home/pauljohn/src/R-devel/builddir/src/library/Recommended'
make[1]: Entering directory `/panfs/pfs.acf.ku.edu/home/pauljohn/src/R-devel/builddir/src/library'
building/updating vignettes for package 'grid' ...
building/updating vignettes for package 'parallel' ...
building/updating vignettes for package 'utils' ...
make[1]: Leaving directory `/panfs/pfs.acf.ku.edu/home/pauljohn/src/R-devel/builddir/src/library'
make[1]: Entering directory `/panfs/pfs.acf.ku.edu/home/pauljohn/src/R-devel/builddir'
configuring Java ...
Java interpreter : /usr/bin/java
Java version : 1.7.0_09-icedtea
Java home path : /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre
Java compiler : /usr/bin/javac
Java headers gen.: /usr/bin/javah
Java archive tool: /usr/bin/jar
trying to compile and link a JNI program 
detected JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
make[2]: Entering directory `/library/tmp/Rjavareconf.wg86X6'
gcc -std=gnu99 -I/home/pauljohn/src/R-devel/builddir/include -I/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre/../include -I/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre/../include/linux -I/usr/local/include -fpic -I/home/pauljohn/packages/include -c conftest.c -o conftest.o
gcc -std=gnu99 -shared -L/home/pauljohn/src/R-devel/builddir/lib -L/home/pauljohn/packages/lib -o conftest.so conftest.o -L/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre/lib/amd64/server -ljvm -L/home/pauljohn/src/R-devel/builddir/lib -lR
make[2]: Leaving directory `/library/tmp/Rjavareconf.wg86X6'
JAVA_HOME : /usr/lib/jvm/java-1.7.0-openjdk-1.7.0.9.x86_64/jre
Java library path: $(JAVA_HOME)/lib/amd64/server
JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
Updating Java configuration in /home/pauljohn/src/R-devel/builddir
Done.
make[1]: Leaving directory `/panfs/pfs.acf.ku.edu/home/pauljohn/src/R-devel/builddir'

 

About pauljohn

Paul E. Johnson is a Professor of Political Science at the University of Kansas. He is an avid Linux User, an adequate system administrator and C programmer, and humility is one of his greatest strengths.
This entry was posted in Linux and tagged , , , . Bookmark the permalink.

41 Responses to Building R-devel on RedHat Linux 6

  1. duongdang says:

    Hello,
    This is very helpful, thanks for sharing!

    One quick question thou’, did you forget to mention any flags for curl? for me autotool is complaining this

    checking for curl/curl.h… yes
    checking if libcurl is version 7 and >= 7.28.0… yes
    checking if libcurl supports https… no
    configure: error: libcurl >= 7.28.0 library and headers are required with support for https

    • pauljohn says:

      I can’t explain the curl problem you see there. In my steps 10 and 11, I put in everything I did. I suspect the problem you see may be that RedHat has updated/changed some RPMs in the time between my effort and yours. Sorry I cannot help.

    • dasicainiao says:

      Install curl:
      env LDFLAGS=-R$HOME/openssl/lib ./configure –prefix=$HOME/packages –with-ssl=$HOME/openssl –with-zlib=$HOME/packages

      make

      make install

      • Aphirox says:

        The formatting of your commands makes no sense to me. Could you go through the explicit steps you followed to solve the error?

        • pauljohn says:

          I’m sorry. This is not clear. What is “the error” or what “commands” don’t make sense to you? I don’t know how I could be more methodical…

        • Hugues says:

          The blogging software has changed the hyphen-minus into em-dash, and therefore simply copy-pasting the last command won’t work.
          Let’s try formatting it:
          [code language=”bash”]
          env LDFLAGS=-R$HOME/openssl/lib ./configure -prefix=$HOME/packages -with-ssl=$HOME/openssl -with-zlib=$HOME/packages
          [/code]

  2. nephantes says:

    Thanks it was extremely helpfull. Every single step, I had the same problems on centos 6.
    Solutions were slightly different but it all worked out.
    Thanks again!
    Alper

  3. ssullivan37 says:

    Thank you so much for these instructions! They got me successfully through the configure, which would not have happened otherwise. When I try to make now, I get an error about the lzma.h file:

    making sock.d from ../../../../../src/library/utils/src/sock.c
    making stubs.d from ../../../../../src/library/utils/src/stubs.c
    making utils.d from ../../../../../src/library/utils/src/utils.c
    ../../../../../src/library/utils/src/utils.c(56): catastrophic error: cannot open source file “lzma.h”

    #include
    make[5]: *** [utils.d] Fehler 4
    make[5]: Leaving directory `/pfs/data1/home/kit/imk-aaf/rj2621/packages/R-3.3.0/builddir/src/library/utils/src’

    I tried copying the lzma.h file from the ~/packages/include directory where it is to the /src/library/utils/src directory where the compiler seems to be looking but no luck. Any idea what the problem might be?
    Thanks again for this post. – Sylvia

    • pauljohn says:

      Sorry, I have not seen that error.

      I am absolutely sure your idea to copy the lzma.h file into the file system is incorrect, that just gives the system the idea that it has a lot of stuff that it does not have.

      I don’t think the configure would finish successfully in this case, I expect it is throwing some warnings at you that you need to read. In your error report, you show just a little bit, and an expert would need to see the whole log starting from configure.

      If I were you, I’d check to see if there is an RPM with a dev package installed with lzma.h, maybe your system has updated itself.

  4. dasicainiao says:

    Thank you pauljohn.

  5. jhallum says:

    I’ve been fighting with this on our cluster for a bit now. My biggest problem is getting tiff compiled in, it’s not even checking for TIFF in the configure script for R, so I’m not sure where the problem is. Ever seen that before?

    • pauljohn says:

      No, I did not hit any TIFF trouble. We have:

      $ rpm -qa | grep tiff

      libtiff-devel-3.9.4-9.el6_3.x86_64
      libtiff-3.9.4-9.el6_3.x86_64

      Maybe you need check if RPMs exist in your system…

  6. Shicheng Guo says:

    Hi Prof. Johnson,

    Thank you so much for the amazing protocol. Yes, it works quite well in the stage of configuration. However, After I run the ‘make’, some error reported as the following:

    It seems about pcre, do you have more suggestion.

    > make
    ……
    gcc -std=gnu99 -I../../src/extra -I. -I../../src/include -I../../src/include -I/usr/local/include -I../../src/nmath -DHAVE_CONFIG_H -fopenmp -fpic -I/home/shg047/software/bzip2-1.0.6 -I/home/shg047/software/zlib-1.2.8 -I/home/shg047/software/xz-5.2.2/include -I/home/shg047/software/pcre-8.38/in clude -I/home/shg047/software/curl-7.47.1/include -c Rmain.c -o Rmain.o
    gcc -std=gnu99 -Wl,–export-dynamic -fopenmp -L../../lib -L/home/shg047/software/bzip2-1.0.6 -L/home/shg047/software/zlib-1.2.8 -L/home/shg047/softwa re/xz-5.2.2/lib -L/home/shg047/software/pcre-8.38/lib -L/home/shg047/software/curl-7.47.1/lib -o R.bin Rmain.o -lR
    /usr/bin/ld: warning: libpcre.so.1, needed by ../../lib/libR.so, not found (try using -rpath or -rpath-link)
    /usr/bin/ld: warning: liblzma.so.5, needed by ../../lib/libR.so, not found (try using -rpath or -rpath-link)
    ../../lib/libR.so: undefined reference to `lzma_code@XZ_5.0′
    ../../lib/libR.so: undefined reference to `lzma_raw_encoder@XZ_5.0′
    ../../lib/libR.so: undefined reference to `lzma_stream_decoder@XZ_5.0′
    ../../lib/libR.so: undefined reference to `pcre_free’
    ../../lib/libR.so: undefined reference to `lzma_lzma_preset@XZ_5.0′
    ../../lib/libR.so: undefined reference to `lzma_raw_decoder@XZ_5.0′
    ../../lib/libR.so: undefined reference to `pcre_version’
    ../../lib/libR.so: undefined reference to `pcre_exec’
    ../../lib/libR.so: undefined reference to `pcre_config’
    ../../lib/libR.so: undefined reference to `pcre_fullinfo’
    ../../lib/libR.so: undefined reference to `pcre_maketables’
    ../../lib/libR.so: undefined reference to `pcre_compile’
    ../../lib/libR.so: undefined reference to `lzma_end@XZ_5.0′
    ../../lib/libR.so: undefined reference to `lzma_alone_decoder@XZ_5.0′
    ../../lib/libR.so: undefined reference to `lzma_version_string@XZ_5.0′
    ../../lib/libR.so: undefined reference to `lzma_crc64@XZ_5.0′
    ../../lib/libR.so: undefined reference to `pcre_study’
    ../../lib/libR.so: undefined reference to `lzma_stream_encoder@XZ_5.0′
    collect2: ld returned 1 exit status
    make[3]: *** [R.bin] Error 1
    make[3]: Leaving directory `/home/shg047/software/R-3.3.0/src/main’
    make[2]: *** [R] Error 2
    make[2]: Leaving directory `/home/shg047/software/R-3.3.0/src/main’
    make[1]: *** [R] Error 1
    make[1]: Leaving directory `/home/shg047/software/R-3.3.0/src’
    make: *** [R] Error 1

    Shicheng

    • pauljohn says:

      I’m guessing there is something wrong in your configure statement, way back at the beginning, and this is the way of telling you you had something missing. Please look at the lib directory of the place where you installed the libraries. You should see libpcre and liblzma in there, and I think your configure does not realize that.

      [pauljohn@n097 lib]$ ls -1
      libbz2.a
      libcurl.a
      libcurl.la
      libcurl.so
      libcurl.so.4
      libcurl.so.4.4.0
      liblzma.a
      liblzma.la
      liblzma.so
      liblzma.so.5
      liblzma.so.5.2.2
      libpcre.a
      libpcre.la
      libpcre.so
      libpcre.so.1
      libpcre.so.1.2.6
      libpcrecpp.a
      libpcrecpp.la
      libpcrecpp.so
      libpcrecpp.so.0
      libpcrecpp.so.0.0.1
      libpcreposix.a
      libpcreposix.la
      libpcreposix.so
      libpcreposix.so.0
      libpcreposix.so.0.0.3
      libz.a
      libz.so
      libz.so.1
      libz.so.1.2.8
      pkgconfig

      I’d delete the R-devel folder, open the tarball again, and run configure again

      • yoonsikp says:

        edit your Makeconf

        nano Makeconf

        scroll down to MAIN_LDFLAGS

        after -Wl,–export-dynamic
        add “,-rpath-link,/home/path/to/lib”

        do not use $HOME !!

  7. yoonsikp says:

    There is an error in step 4

    The quotation marks have been converted to smart quotes, and therefore copying and pasting the line makes the compiler stop working.

  8. vikas_kache says:

    This was extremely helpful. Probably saved me tens of hours.

    I was able to also install 3.3.1 with slightlymore updated versions of libcurl. I did have root access on the machine, but will have to try without it.

  9. vivek says:

    This article was extremely helpful. I was just following step by step and was facing same issues. Thanks a lot Paul

  10. davidroad says:

    Thanks a lot prof.Johnson. This is really helpful.
    I follow all the step you did.
    I insert ‘-fpic -fPIC’ to the setting of CFLAGS in Makefile of bzip2.
    It worked great, and I think have already finished. However, it came out some error when compile the basic package ‘Matrix’. I really do not know what’s wrong with it.
    And I use gcc-4.6.1, gcc-4.9.0,gcc-5.2.0, and all failed in the process of installing this ‘Matrix’ package. Some of my colleagues, they succeeded by following your protocol without having my problem. We use the same OS! I felt so upset about it.
    Is there anyone who occurred the same problem?
    * installing *source* package âMatrixâ …
    ** package âMatrixâ successfully unpacked and MD5 sums checked
    ** libs
    make[3]: Entering directory `/tmp/RtmpLKClCy/R.INSTALL9dd96bb28358/Matrix/src’
    gcc -I/home/daiy2/src/R-3.3.1/builddir/include -DNDEBUG -DNTIMER -I./SuiteSparse_config -I/usr/local/include -fpic -I/home/daiy2/R/include -c CHMfactor.c -o CHMfactor.o
    In file included from CHMfactor.h:4:0,
    from CHMfactor.c:2:
    Mutils.h: In function âinv_permutationâ:
    Mutils.h:303:5: error: âforâ loop initial declarations are only allowed in C99 mode
    Mutils.h:303:5: note: use option -std=c99 or -std=gnu99 to compile your code
    In file included from Mutils.h:472:0,
    from CHMfactor.h:4,
    from CHMfactor.c:2:
    t_sparseVector.c: In function âdsparseVector_subâ:
    t_sparseVector.c:139:5: error: âforâ loop initial declarations are only allowed in C99 mode
    In file included from Mutils.h:475:0,
    from CHMfactor.h:4,
    from CHMfactor.c:2:
    t_sparseVector.c: In function âisparseVector_subâ:
    t_sparseVector.c:139:5: error: âforâ loop initial declarations are only allowed in C99 mode
    In file included from Mutils.h:478:0,
    from CHMfactor.h:4,
    from CHMfactor.c:2:
    t_sparseVector.c: In function âlsparseVector_subâ:
    t_sparseVector.c:139:5: error: âforâ loop initial declarations are only allowed in C99 mode
    In file included from Mutils.h:481:0,
    from CHMfactor.h:4,
    from CHMfactor.c:2:
    t_sparseVector.c: In function ânsparseVector_subâ:
    t_sparseVector.c:139:5: error: âforâ loop initial declarations are only allowed in C99 mode
    In file included from Mutils.h:484:0,
    from CHMfactor.h:4,
    from CHMfactor.c:2:
    t_sparseVector.c: In function âzsparseVector_subâ:
    t_sparseVector.c:139:5: error: âforâ loop initial declarations are only allowed in C99 mode
    make[3]: *** [CHMfactor.o] Error 1
    make[3]: Leaving directory `/tmp/RtmpLKClCy/R.INSTALL9dd96bb28358/Matrix/src’
    ERROR: compilation failed for package âMatrixâ
    * removing â/gpfs22/home/daiy2/src/R-3.3.1/builddir/library/Matrixâ
    make[2]: *** [Matrix.ts] Error 1
    make[2]: Leaving directory `/gpfs22/home/daiy2/src/R-3.3.1/builddir/src/library/Recommended’
    make[1]: *** [recommended-packages] Error 2
    make[1]: Leaving directory `/gpfs22/home/daiy2/src/R-3.3.1/builddir/src/library/Recommended’
    make: *** [stamp-recommended] Error 2

    • pauljohn says:

      Hm. I’m guessing that you think you are getting the right gcc and g++, but you are not because you are apparently trying lots of variations without cleaning up after yourself.

      Yesterday, I noticed my blog formatting was broken and the gcc module selection was slammed into end of a paragraph. I just separated that. Anyway, if I were you, I would clean out the R build directory (if you did it inside the source tree, you need to open a new copy), then get the gcc set that you need, and if you are doing it some way different than a module, make sure you set not only gcc, but g++. I’m on 4.9.22. Run the R compile top to bottom in the clean tree.

      If you don’t have a clean tree, then when you try with the wrong compiler, some symbols are created and saved. Then you change your gcc, and run again, but the old symbols are stuck where they were. The compiler does not try to re-do its work.

      That’s why I wished I had written this out to build in a separate folder, so I could obliterate the build folder between tries.

      • davidroad says:

        Hi Prof. Johnson,
        Thanks a lot for the reply. I think I found the mistake is the Interfaces supported. I can’t find the tcltk even with the command ‘–with-tcltk’. I will make it right and see if I could compiler all.

  11. osama says:

    Hi Prof. Johnson,

    This is really helpful. I have followed all steps and both configure and make went well (without errors). However, I can NOT run R! Sorry if my background of this is poor. I just tried to run R from Ubuntu terminal by just typing R. It returns:

    “The program ‘R’ is currently not installed. You can install it by typing:
    sudo apt-get install r-base-core”

    I wanted to Installing R from source (speciffically, Version 3.3.1). Here is a copy of the last few lines that make return when I followed you whole process:

    make[2]: Leaving directory `/usr/local/src/R-3.3.1/builddir/src/library/Recommended’
    make[1]: Leaving directory `/usr/local/src/R-3.3.1/builddir/src/library/Recommended’
    make[1]: Entering directory `/usr/local/src/R-3.3.1/builddir/src/library’
    building/updating vignettes for package ‘grid’ …
    building/updating vignettes for package ‘parallel’ …
    building/updating vignettes for package ‘utils’ …
    make[1]: Leaving directory `/usr/local/src/R-3.3.1/builddir/src/library’
    make[1]: Entering directory `/usr/local/src/R-3.3.1/builddir’
    configuring Java …
    Java interpreter : /usr/bin/java
    Java version : 1.8.0_101
    Java home path : /usr/lib/jvm/java-8-oracle/jre
    Java compiler : /usr/bin/javac
    Java headers gen.: /usr/bin/javah
    Java archive tool: /usr/bin/jar

    trying to compile and link a JNI program
    detected JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
    detected JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
    make[2]: Entering directory `/tmp/Rjavareconf.OSpeMR’
    gcc -std=gnu99 -I/usr/local/src/R-3.3.1/builddir/include -DNDEBUG -I/usr/lib/jvm/java-8-oracle/jre/../include -I/usr/lib/jvm/java-8-oracle/jre/../include/linux -I/usr/local/include -fpic -I/home/osama/packages/include -c conftest.c -o conftest.o
    gcc -std=gnu99 -shared -L/usr/local/src/R-3.3.1/builddir/lib -L/home/osama/packages/lib -o conftest.so conftest.o -L/usr/lib/jvm/java-8-oracle/jre/lib/amd64/server -ljvm -L/usr/local/src/R-3.3.1/builddir/lib -lR
    make[2]: Leaving directory `/tmp/Rjavareconf.OSpeMR’

    JAVA_HOME : /usr/lib/jvm/java-8-oracle/jre
    Java library path: $(JAVA_HOME)/lib/amd64/server
    JNI cpp flags : -I$(JAVA_HOME)/../include -I$(JAVA_HOME)/../include/linux
    JNI linker flags : -L$(JAVA_HOME)/lib/amd64/server -ljvm
    Updating Java configuration in /usr/local/src/R-3.3.1/builddir
    Done.

    make[1]: Leaving directory `/usr/local/src/R-3.3.1/builddir’

    • pauljohn says:

      It appears you did your install on a Debian system, not on RedHat or Centos.

      I believe you may have forgotten to add the install directory “bin” to your path.

      Try this test. “cd” into the directory where you installed R. cd into the bin directory there. That would have been specified in the configure script’s prefix argument. In there, run “./R”

  12. pgajer says:

    Thank you for posting these instructions ! I wonder if you know how can I get rid of the error

    make[4]: Entering directory `/local/projects/pgajer/devel/packages/R-3.3.1/builddir/src/library/compiler’
    byte-compiling package ‘compiler’
    Error: package ‘compiler’ was built before R 3.0.0: please re-install it
    Execution halted
    make[4]: *** [../../../library/compiler/R/compiler.rdb] Error 1

    Thanks !
    🙂
    pawel

    • pauljohn says:

      Oh, can I guess what’s wrong?

      In your user account, or possibly in the system-wide version of R, the old package “compile” is being found because it is in your path. I recall one case in which I had to move ~/R entirely, or else old version was found. I recall also one case where I had to alter the PATH so that the versions of R packages built during the R compile were found ahead of ones installed in /usr/share/R.

      If that does not help, let me know, I’m going to have to rebuild R-3.3.1 sometime soon.

      Oh, one warning. It always helps to start the build with a clean source directory.

  13. MIArvas says:

    Thanks, this was a wonderful post. I managed to install R to a custom location on a Centos server with these instructions I only got stuck on the CURL part.
    ….
    checking for curl-config… /usr/local/bin/curl-config
    checking libcurl version … 7.47.1
    checking curl/curl.h usability… yes
    checking curl/curl.h presence… yes
    checking for curl/curl.h… yes
    checking if libcurl is version 7 and >= 7.28.0… yes
    checking if libcurl supports https… no
    configure: error: libcurl >= 7.28.0 library and headers are required with support for https

    After a lot of stupid things I realised that the server lacked openssl:
    $ sudo yum install openssl-devel

    With this fixed, I needed to update curl, but also pycurl and things started working.

    Thanks again,
    Mikko

    • disha7003 says:

      Hi Mikko,

      I am facing the same issues while trying to build 3.3.1. I did install openssl and try building again, but again the same error. Could you please share your code?

      Thank you,
      Disha

  14. king108 says:

    trying to build R-3.3.0 and would love help.

    I’m stuck at liblzma. I installed the xz library as you did in the directions, but I keep on getting the same error:
    checking lzma.h presence… yes
    checking for lzma.h… yes
    checking if lzma version >= 5.0.3… no
    I tried doing yum install liblzma. but I still get no where and it says package doesn’t exist…

    any other suggestions?

    • pauljohn says:

      It finds an outdated lzma. Humphf!

      First, lets check what you installed:

      In your ~/packages/include/lzma folder, look for version.h. Open that:

      You should find something like (which I see now)


      #define LZMA_VERSION_MAJOR 5
      #define LZMA_VERSION_MINOR 2
      #define LZMA_VERSION_PATCH 2

      If your version information is good, then the only possible explanation is that there is another, older lzma floating about. It is possibly finding a too-old lzma in your system?

  15. disha7003 says:

    Hi Paul,

    Firstly, thanks for this step by step guide, very helpful.

    I am trying to build R 3.3.1 on RHEL 5 and failing at below error.
    configure: error: libcurl >= 7.28.0 library and headers are required with support for https

    I have tried using the latest libcurl and few other fixes online. Nothing really works. Could you help out?

    Thank you again,
    Disha

  16. pankaj says:

    Thanks for the instructions. I am trying to install version 3.3.2 of R from source and got stuck in step 4 of “configure”. I was able to install the zlib header and library but I cannot get “configure” to find it. I tried two different ways, but each time when I run configure it stop with the error message:
    checking if zlib version >= 1.2.5… no
    checking whether zlib support suffices… configure: error: zlib library and headers are required

    The two different ways I tried to run configure are:
    1.
    export CFLAGS=/srv/agarw005/installs/packages/install/zlib-1.2.11/include/
    export LDFLAGS=/srv/agarw005/installs/packages/install/zlib-1.2.11/lib/
    $ /srv/agarw005/temp/R332Install/R-3.3.2/configure –prefix=/srv/agarw005/temp/R332Install/install/build1/

    2.
    export MY_INC_PATH=/srv/agarw005/installs/packages/install/zlib-1.2.11/include/
    export MY_LIB_PATH=/srv/agarw005/installs/packages/install/zlib-1.2.11/lib/
    $ /srv/agarw005/temp/R332Install/R-3.3.2/configure –prefix=/srv/agarw005/temp/R332Install/install/build1/ CFLAGS=”-I${MY_INC_PATH}” LDFLAGS=”-L${MY_LIB_PATH}”

    My “system” version of zlib is 1.2.3 as shown by
    $ rpm -q zlib
    zlib-1.2.3-29.el6.x86_64

    Is there some other way I can make the latest install of zlib visible to configure?

    Thanks,

    – Pankaj

  17. Pingback: Horrible configure script – zeusville

  18. jguerra says:

    Hello Prof. Johnson,

    I am seeing the -fPIC error as you mentioned in step 12. So, just to make sure I am doing everything right; when I go to the bzip folder and I open the Makefile I have to add the ‘-fPIC’ argument to the CFLAGS variable in this matter:

    CFLAGS=-fPIC -Wall -Winline -O2 -g $(BIGFILES)

    or should I do something different?

    Thank you for your help!

    • jguerra says:

      I was able to make it work by modifying both ‘Makefile’ and ‘Makefile-libbz2_so’ files. I changed the line
      CC =gcc
      to
      CC =gcc -fPIC

      Thank you for the guide.

  19. fakechek says:

    Hey Paul! Thanks for this fantastic article! I suffer from terrible cluster maintenance and therefore have to take things into my own hands by installing a new R version by hand.

    Everything went more or less exactly to your description, until the second last step (end of step 12), where your ‘make’ command fails because of the bzip2 library. For me it also fails, but because it can’t find ‘zlib.h’. Since I followed your script step by step, the file is located in $HOME/packages/include/zlib.h. Here are the last lines of the make output:

    In file included from ../../../src/main/connections.c:1438:0:
    ../../../src/main/gzio.h:38:18: fatal error: zlib.h: No such file or directory
    #include “zlib.h”
    ^
    compilation terminated.
    make[2]: *** [connections.d] Error 1
    make[2]: Leaving directory `/mnt/PGP/homes/rhillje/src/R-3.4.0/builddir/src/main’
    make[1]: *** [R] Error 1
    make[1]: Leaving directory `/mnt/PGP/homes/rhillje/src/R-3.4.0/builddir/src’
    make: *** [R] Error 1

    I checked the LD_LIBRARY_PATH to make sure it is set up as you said, then I also added $HOME/packages/include to make sure the path is in there. This is what my LD_LIBRARY_PATH looks like (I replaced my home path with $HOME):

    $HOME/packages/lib:$HOME/packages/include

    Anyway it fails.

    Anybody an idea what to do? I googled for some time but wasn’t successful yet. Somebody suggested adding a ‘-I’ flag to the ‘make’ command, such as ‘make -I$HOME/packages/include’ but also that failed.

    Any help is appreciated!

  20. jaison says:

    Professor Paul E. Johnson,

    You made my day!!!!
    Thanks a lot, mate.

    Regards,
    Jaison.

  21. Pingback: Compiling R-3.4.2 on CentOS 6 with GNU – Linux Cluster

  22. martingale says:

    Thanks very much for the help!
    When installing Zlib, I met the issue below.

    I first run ./configure –prefix=$HOME/packages and it looks OK.

    ia64-cross: ./configure –prefix=$HOME/packages
    Checking for shared library support…
    Building shared library libz.so.1.2.8 with /xenv/C/ia64/4.1.2r5_64/RH5.6AS_64/usr/bin/ia64cc.
    Checking for off64_t… Yes.
    Checking for fseeko… Yes.
    Checking for strerror… Yes.
    Checking for unistd.h… Yes.
    Checking for stdarg.h… Yes.
    Checking whether to use vs[n]printf() or s[n]printf()… using vs[n]printf().
    Checking for vsnprintf() in stdio.h… Yes.
    Checking for return value of vsnprintf()… Yes.
    Checking for attribute(visibility) support… Yes.

    Then I run make and there’s error.

    ia64-cross: make
    /xenv/C/ia64/4.1.2r5_64/RH5.6AS_64/usr/bin/ia64cc -I/home/bw03303/packages/include -D_LARGEFILE64_SOURCE=1 -DHAVE_HIDDEN -I. -c -o example.o test/example.c
    test/example.c:29: error: expected â=â, â,â, â;â, âasmâ or â__attribute__â before âcharâ
    test/example.c: In function âtest_compressâ:
    test/example.c:93: error: âhelloâ undeclared (first use in this function)
    test/example.c:93: error: (Each undeclared identifier is reported only once
    test/example.c:93: error: for each function it appears in.)
    test/example.c: In function âtest_gzioâ:
    test/example.c:123: error: âhelloâ undeclared (first use in this function)
    test/example.c: In function âtest_deflateâ:
    test/example.c:206: error: âhelloâ undeclared (first use in this function)
    test/example.c:215: error: âz_constâ undeclared (first use in this function)
    test/example.c:215: error: expected â)â before âunsignedâ
    test/example.c:215: error: expected â;â before âhelloâ
    test/example.c: In function âtest_inflateâ:
    test/example.c:268: error: âhelloâ undeclared (first use in this function)
    test/example.c: In function âtest_flushâ:
    test/example.c:381: error: âhelloâ undeclared (first use in this function)
    test/example.c:390: error: âz_constâ undeclared (first use in this function)
    test/example.c:390: error: expected â)â before âunsignedâ
    test/example.c:390: error: expected â;â before âhelloâ
    test/example.c: In function âtest_dict_deflateâ:
    test/example.c:479: error: âz_constâ undeclared (first use in this function)
    test/example.c:479: error: expected â)â before âunsignedâ
    test/example.c:479: error: expected â;â before âhelloâ
    test/example.c:480: error: âhelloâ undeclared (first use in this function)
    test/example.c: In function âtest_dict_inflateâ:
    test/example.c:533: error: âhelloâ undeclared (first use in this function)
    make: *** [example.o] Error 1

    I ignore this error msg and run make install. But when installing R, zlib still cannot be found.

    checking whether zlib support suffices… configure: error: zlib library and headers are required.

    Do you know what could possibly be the reason? Thanks!!

  23. Maliang says:

    Professor Paul E. Johnson,:
    When I make R, Then display:
    **************************************************************
    building package ‘base’
    make[4]: Entering directory `/iot_water/R-3.4.2/src/library/base’
    ls: cannot access ./R/*.R: No such file or directory
    ls: cannot access ./R/unix/*.R: No such file or directory
    **************************************************************
    Ever seen that before?
    Thank you for your help!

    • Maliang says:

      I have solved the problem.
      1. rm -rf R-3.4.2
      2. tar -xvcf R-3.4.2.tar.gz
      3. sudo ./configure –enable-R-shlib LDFLAGS=”-L/iot_water/package/lib” CPPFLAGS=”-I/iot_water/package/include”
      4. sudo make

Leave a Reply