22

Trying to install R-3.3.2 but when I use $./configure, I keep getting the error:

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

InformaticsLad
  • 221
  • 1
  • 2
  • 6
  • 1
    I have bzip2 installed: `$ bzip2` then `bzip2: I won't write compressed data to a terminal` `bzip2: For help, type: "bzip2 --help"` – InformaticsLad Nov 16 '16 at 18:12
  • I have encountered the same problem, hope you can post the solution here when you solved this problem. Thank you! – pengchy Dec 27 '16 at 08:48
  • 2
    @pengchy I had the same problem with `zlib`, I found out that, strangely, the source code's `configure` script checks the version numbers by `strcmp`. My installed zlib version was "1.2.11", and the minimum requirement is "1.2.6" which is lexicographically smaller. I changed that line and it worked. – cartoonist Feb 06 '17 at 20:20
  • 1
    @pengchy I explained it [here](http://stackoverflow.com/questions/42076936/zlib-bz2-library-and-headers-are-requried-for-compiling-r) – cartoonist Feb 06 '17 at 20:54
  • @cartoonist thank you, I have successfully [installed R-3.3.2 from the source file](http://stackoverflow.com/questions/40639138/configure-error-installing-r-3-3-2-on-ubuntu-checking-whether-bzip2-support-suf/41362423#41362423) – pengchy Feb 06 '17 at 22:42
  • Installing the latest developmental version of bz2, `apt-get install libbz2-dev` as of 02/14/17 solved this problem for me. – msakya Feb 14 '17 at 17:13

3 Answers3

18

It worked for me after:

sudo apt-get install libbz2-dev
Yves Cavalcanti
  • 339
  • 2
  • 5
5

I have successfully compiled R from source, the following steps need special attention:

  1. install dependent libraries: zlib-1.2.8, bzip2-1.0.6, xz-5.2.2, pcre-8.39, curl-7.52.1. Specifically, to compile bzip2, The Makefile should be modified: original: CC=gcc after modification: CC=gcc -fPIC

  2. pass the library and header file to the configure with proper variables:

    export CPATH=/opt/zlib-1.2.8/include/:/opt/bzip2-1.0.6/include/:/opt/xz-5.2.2/include/:/opt/pcre-8.39/include/

    export LD_LIBRARY_PATH=/opt/zlib-1.2.8/lib/:/opt/bzip2-1.0.6/lib/:/opt/xz-5.2.2/lib/:/opt/pcre-8.39/lib/

    ./configure --prefix=/opt/R/R_soft/ --enable-R-shlib --with-libpth-prefix=/opt/ CPPFLAGS="-I/opt/bzip2-1.0.6/include/ -I/opt/zlib-1.2.8/include/ -I/opt/xz-5.2.2/include/ -I/opt/pcre-8.39/include/ -I/opt/curl-7.52.1/include/" LDFLAGS="-L/opt/xz-5.2.2/lib/ -L/opt/zlib-1.2.8/lib/ -L/opt/bzip2-1.0.6/lib/ -L/opt/pcre-8.39/lib/ -L/opt/curl-7.52.1/lib/"

It seems CPATH and CPPFLAGS is redundant here, I found the CPPFLAGS AND LDFLAGS not worked.

pengchy
  • 732
  • 2
  • 14
  • 26
1

First off, are you aware that you can get prebuilt binaries of current R ?

Second, your comment on the bzip2 binary has no bearing on the need for the library R needs to compile and link against.

Third, you can search: apt-cache search bzip2 | grep library would have gotten you there.

Fourth, for all existing packages you can actually install their known build dependencies. But see point one, you probably do not want to build from source.

Fifth, and closing: sudo apt-get install libbz2-dev answers your (narrow) question but you will likely have further issues. There is an entire manual devoted to installing and administering R which has all the answers for you.

Dirk Eddelbuettel
  • 360,940
  • 56
  • 644
  • 725
  • 7
    The error indeed exist. Because I want to install R into my own directory on the Linux server, so the bzip2 source file is compiled before installing R 3.3.2. However, the "checking if bzip2 version >= 1.0.6... no" error still exist although the version bzip2 indeed 1.0.6. – pengchy Dec 27 '16 at 08:46
  • I can't understand the prebuilt installation instructions. It says to add the code to '/etc/apt/sources.list' but I have no idea what this is. What happened to downloading and installing tars... – Garglesoap Jul 16 '18 at 16:40
  • Nobody is taking source downloads away from me. We "merely" prebuilt binaries created and customized by people familiar with the source package at hand. I, and a lot of ther people, find that preferable. As for `/etc/apt/sources.list`, try one of the many basic tutorials for Debian or Ubuntu package management. HTH. – Dirk Eddelbuettel Jul 16 '18 at 16:43