0

I'm trying to compile R-3.4.1 on a server I have access to (but not root access). The script compilation fails because of zlib version. I follow the instruction here, and I compile zilb and it is available in the path /storage/users/<uname>/trm/zlib/lib I tried to add this path to both $LD_LIBRARY_PATH and to $LIBRARY_PATH$ and it doesn't work. I also tried, as per the link above to run the configure as following:

$ ./configure --prefix=/storage/users/<uname>/trm/R LDFLAGS="-L/storage/users/<uname>/trm/zlib/lib"

but the error remains. The configure script itself doesn't have the bug mentioned in the link above. Sadly, I don't know what is the distro on the server. Clearly, I'm missing something, but I don't know what.


edit 1

These are the final lines of the ./configure command

checking zlib.h usability... yes
checking zlib.h presence... yes
checking for zlib.h... yes
checking if zlib version >= 1.2.5... no
checking whether zlib support suffices... configure: error: zlib library and headers are required

(I tried this with @PSkocik suggestion)

also, to confirm, I copy paste the path I used for the configure command into ls:

libz.a  libz.so  libz.so.1  libz.so.1.2.11  pkgconfig

Edit 2
Following @AmeyaVS instructions, I post here the content of zlib.pc

prefix=/storage/users/<uname>/trm/zlib
exec_prefix=${prefix}
libdir=${exec_prefix}/lib
sharedlibdir=${libdir}
includedir=${prefix}/include

Name: zlib
Description: zlib compression library
Version: 1.2.11

Requires:
Libs: -L${libdir} -L${sharedlibdir} -lz
Cflags: -I${includedir}
  • 1
    "The script compilation fails because of zlib version" what is the complete error message? I suspect you will need to supply the header file include path (perhaps via CFLAGS), not only the library path. BTW did you mean R-3.4.1? – steeldriver Jul 23 '17 at 21:25
  • Try LDFLAGS="-L/storage/users/<uname>/trm/zlib/lib" ./configure --prefix=/storage/users/<uname>/trm/R, that'll definitely set the environment variable. Your version will only do that if the configure script will cooperate. – PSkocik Jul 23 '17 at 21:48
  • @steeldriver, I added the final lines of the configure command. You are are right about the version number, I fixed that. – Yotam Jul 24 '17 at 5:51
  • @PSkocik, I tried with your suggestion and still no go – Yotam Jul 24 '17 at 5:51
1

You need to provide the configure script with the pkg-config script path of the zlib library.

Here is what I usually do when building GNU Autotools libraries:

# First unzip the files from the library zipped file.
tar xvf zlib-1.2.11.tar.gz
cd zlib-1.2.11
# if it has **configure** script in the source directory
mkdir objdir
cd objdir
# Set this environment variable from where you want to install the library.
# export ZLIB_HOME=<path where you want to install zlib>
export ZLIB_HOME=$HOME/apps/zlib
../configure --prefix=$ZLIB_HOME
# Build the library
make
# Install the library
make install
# Set the PKG_CONFIG_PATH if PKG_CONFIG_PATH is not set for pkgconfig to locate the build flags for the library.
export PKG_CONFIG_PATH=$ZLIB_HOME/lib/pkgconfig
# or use this in-case the PKG_CONFIG_PATH is not empty:
# export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$ZLIB_HOME/lib/pkgconfig

Now try configuring the R package within the same terminal session.

Note:
What I usually do is add the environment variable for the library in my $HOME/.bashrc(assuming you are using bash shell, kindly find the respective file for your terminal session) file like this for the library to be persistent for newer installation of other packages requiring this library:

export ZLIB_HOME=$HOME/apps/zlib
# Assuming LD_LIBRARY_PATH is already populated.
export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:$ZLIB_HOME/lib
# Assuming PKG_CONFIG_PATH is already populated.
export PKG_CONFIG_PATH=$PKG_CONFIG_PATH:$ZLIB_HOME/lib/pkgconfig

Update:
You can find the version and the include path specified for any library using following commands:

# Check module/library version
# pkg-config --modversion <library_name>
pkg-config --modversion zlib
# Check compiler include flag for the specified library.
# pkg-config --cflags <library_name>
pkg-config --cflags zlib

If you are getting zlib version as 1.2.11 and the gcc include path as
-I/storage/users/<uname>/trm/zlib/include and still the configure script for R reports the zlib version as 1.2.5 then most probably the configure script is looking for the dependent library at very specified location.

  • I didn't understand the objdir creation part. I create an empty folder and I enter and there is nothing compile there. I skipped this part, and recompiled the files, I added the PKG_CONFIG_PATH part and ended up with the same result. – Yotam Jul 24 '17 at 8:35
  • objdir is for building the code out of source tree build operation. I ran the ../configure script from the source directory of the zlib library source directory. In-case you are still getting the error kindly cleanup the source directory with extra files generated during the configure step. – AmeyaVS Jul 24 '17 at 9:25
  • Hi, I removed the folder, and untared the source again and followed your instructions with the exception of putting the zlib path at the end and not the beginning of the LD_LIBRARY_PATH since I already have an older version of zlib installed on that machine. It still doesn't work – Yotam Jul 24 '17 at 11:22
  • Clean up the R configure script output also. It is better to build the source out of the source tree in a separate directory. Also post the contents of the zlib.pc contained in the zlib lib/pkconfig directory. – AmeyaVS Jul 24 '17 at 11:23
  • I got the same result after using a fresh untar of R with the same result. I posted also the content of zlib.pc in my original question. – Yotam Jul 24 '17 at 11:35

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.