Installing ShortRead - error: zlib not found even with zlib in LD_LIBRARY_PATH
5
5
Entering edit mode
@josephelsherbini-15796
Last seen 6.6 years ago

I am unable to install ShortRead which I need for dada2

R version 3.4.3 (2017-11-30)

biocLite(c("ShortRead"))

...

checking for gzeof in -lz... no
configure: error: zlib not found
ERROR: configuration failed for package ‘ShortRead’

However, I do have libz available:

Sys.getenv()

...

LD_LIBRARY_PATH         /home/josephe/miniconda3/envs/dada2pipeline/lib/R/lib:/builddir/vendor/build/lib:/usr/lib/jvm/java-1.7.0-openjdk-1.7.0.111.x86_64/jre/lib/amd64/server:/home/josephe/miniconda3/envs/dada2pipeline/lib

ls -l ~/miniconda3/envs/dada2pipeline/lib/libz*
-rw-rw-r-- 4 josephe josephe 153418 Jan 23  2017 /home/josephe/miniconda3/envs/dada2pipeline/lib/libz.a
lrwxrwxrwx 2 josephe josephe     14 May 11 12:30 /home/josephe/miniconda3/envs/dada2pipeline/lib/libz.so -> libz.so.1.2.11
lrwxrwxrwx 2 josephe josephe     14 May 11 12:30 /home/josephe/miniconda3/envs/dada2pipeline/lib/libz.so.1 -> libz.so.1.2.11
package installation shortread dependency • 11k views
ADD COMMENT
1
Entering edit mode
@martin-morgan-1513
Last seen 4 months ago
United States

I'd ensure that this was seen by R, and that the header for libz (typically, installing the '-dev' version of the library) are available.

As a next step, if from the command line and with the unpacked source tarball available you try to install the package

> download.packages("ShortRead", ".", repos = BiocInstaller::biocinstallRepos())
> quit()
$ tar xzf ShortRead_*gz
$ cd ShortRead
ShortRead$ R CMD INSTALL .

and then look for config.log you'll see something like

configure:2897: checking for gzeof in -lz
configure:2922: gcc -o conftest -g -O2   conftest.c -lz   >&5
configure:2922: $? = 0
configure:2931: result: yes

except that you won't get that result, and there'll be a conftest.c file and perhaps informative messages. I'd also look on the mailing list / support site for whatever 'conda' manager you're using for similar messages.

ADD COMMENT
1
Entering edit mode
I get the error "cannot find -lz". Do you have any insight into that? I think I have zlib version 1.2.11 installed, it is in the directory /home/josephe/miniconda3/envs/dada2pipeline/lib, and my LD_LIBRARY_PATH is set to that directory.
configure:2897: checking for gzeof in -lz
configure:2922: /home/josephe/miniconda3/envs/dada2pipeline/bin/x86_64-conda_cos6-linux-gnu-cc -o conftest -march=nocona -mtune=haswell -ftree-vectorize -fPIC -fstack-
protector-strong -fno-plt -O2 -pipe -DNDEBUG -D_FORTIFY_SOURCE=2 -O2 -Wl,-O2 -Wl,--sort-common -Wl,--as-needed -Wl,-z,relro -Wl,-z,now conftest.c -lz   >&5
/home/josephe/miniconda3/envs/dada2pipeline/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.2.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status
configure:2922: $? = 1
configure: failed program was:
| /* confdefs.h */
| #define PACKAGE_NAME ""
| #define PACKAGE_TARNAME ""
| #define PACKAGE_VERSION ""
| #define PACKAGE_STRING ""
| #define PACKAGE_BUGREPORT ""
| #define PACKAGE_URL ""
| /* end confdefs.h.  */
| 
| /* Override any GCC internal prototype to avoid an error.
|    Use char because int might match the return type of a GCC
|    builtin and then its argument prototype would still apply.  */
| #ifdef __cplusplus
| extern "C"
| #endif
| char gzeof ();
| int
| main ()
| {
| return gzeof ();
|   ;
|   return 0;
| }
configure:2931: result: no
configure:2941: error: zlib not found
ADD REPLY
0
Entering edit mode

You can see the command begin run (the stuff after the line configure:2922:) on the file echoed in the | comment. I'd guess it is that the LD_LIBRARY_PATH is either incorrect or not forwarded to the process that does the compilation and installation. You could edit the configure.ac file to echo what configure is seeing

AC_INIT("DESCRIPTION")
echo "LD_LIBRARY_PATH: $LD_LIBRARY_PATH"
AC_CHECK_LIB([z], [gzeof], , AC_ERROR([zlib not found]))
AC_CHECK_SIZEOF([unsigned long]) AC_OUTPUT(src/Makevars)

then use autoconf and R CMD INSTALL; I have

ShortRead master$ autoconf
ShortRead master$ bioc-dev CMD INSTALL .
* installing to library '/home/mtmorgan/R/x86_64-pc-linux-gnu-library/3.5-Bioc-3.8'
* installing *source* package 'ShortRead' ... 
LD_LIBRARY_PATH: /home/mtmorgan/bin/R-3-5-branch/lib:/usr/local/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/jvm/java-9-openjdk-amd64/lib/amd64/server:/home/mtmorgan/bin/R-3-5-branch/lib:/usr/local/lib:/usr/lib/x86_64-linux-gnu:/usr/lib/jvm/java-9-openjdk-amd64/lib/amd64/server

If LD_LIBRARY_PATH is not correct, then I'm not really sure what to do -- I think it is really a conda problem.

ADD REPLY
0
Entering edit mode

I am also facing the same issue with R version 3.4.3 installed via anaconda3.5.2. Did you find any solution for this problem? 
Thanks!

ADD REPLY
0
Entering edit mode

did you try to troubleshoot as above? what were the results?

ADD REPLY
0
Entering edit mode

Yes. No luck with that!  Echoing LD_LIBRARY_PATH shows that anaconda lib is included. I am not sure why the package still can't find zlib.
checking for gzeof in -lz... no
configure: error: zlib not found

 

ADD REPLY
0
Entering edit mode

Hi Martin,

I have the same problem with the same versions etc. I tried your troubleshooting method, but it just gives the same error that I get in the R console, the one posted above. This is also using conda. Installing ShortRead via conda will unfortuately downgrade R and some other things as I guess they don't have the current version yet.

ADD REPLY
3
Entering edit mode

I finally figured out setting CPPFLAGS and LDFLAGS works:

CPPFLAGS='-I/home/till/miniconda2/envs/dada2/include' LDFLAGS='-L/home/till/miniconda2/miniconda2/envs/dada2/lib'

What does NOT work however is

R CMD INSTALL --configure-args='--with-zlib-include=home/till//miniconda2/envs/dada2/include --with-zlib-lib=/home/till/miniconda2/envs/dada2/lib' .

ADD REPLY
0
Entering edit mode

Thanks for working on this. It sounds like a bioconda issue (I guess -- is that what creates the 'miniconda2' directory?), and that somehow R should know to look in the paths you indicate for the include and lib files. Can you pursue this 'upstream' with the bioconda team?

ADD REPLY
0
Entering edit mode

 Could you please tell us what exactly you did?
This didn't work for me.

export CPPFLAGS="-I~/panases_soft/anaconda3.5.2/include"
export LDFLAGS="-L~/panases_soft/anaconda3.5.2/lib"

 

ADD REPLY
0
Entering edit mode

Just add those lines at configure:2889

CPPFLAGS='-I/home/miniconda3/envs/yourenvname/include'

LDFLAGS='-L/home/miniconda3/envs/yourenvname/lib'

ADD REPLY
1
Entering edit mode

Have you taken this issue up with the upstream conda installation that you are using? It needs to be fixed there rather than through fragile hacks like this.

ADD REPLY
0
Entering edit mode

Thank you! Thank you! This saved me tons of time!

ADD REPLY
1
Entering edit mode
olavur ▴ 10
@olavur-16765
Last seen 6.0 years ago

I had what seems to be the exact same problem, installing ShortRead in a conda environment. I was able to solve the problem for myself, so I hope this can help others having the same issue.

Long story short, this error seems to happen with zlib v1.2.11 but not zlib v1.2.8. So I made sure my environment was using this version:

$ conda create -n myenv zlib=1.2.8

After this, installing ShortRead worked fine.

$ source activate myenv
$ R
> source("https://bioconductor.org/biocLite.R")
> biocLite("ShortRead")

Note that it might be possible to downgrade zlib:

$ conda install -c anaconda zlib=1.2.8

However, in my case this broke some other packages, which is why I had to create an entirely new environment. Hope this helps.

ADD COMMENT
0
Entering edit mode

For what it's worth and in an attempt at a reproducible example, I did

sh ~/Downloads/Miniconda3-latest-Linux-x86_64.sh
conda config --add channels defaults
conda config --add channels conda-forge
conda config --add channels bioconda
conda create -n bioconductor bioconductor-biocinstaller
conda activate bioconductor
conda install bioconductor-shortread

and had no trouble.

 

In the failing configuration, if you clone the ShortRead package

git clone https://git.bioconductor.org/packages/ShortRead
cd ShortRead

and run

./configure

it should fail. Does it also report, in the config.log file that should now exist, a line like the one above, 

...gnu/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status

? If so, can you further simplify the problem by creating a file conftest.c

/* confdefs.h */
#define PACKAGE_NAME ""
#define PACKAGE_TARNAME ""
#define PACKAGE_VERSION ""
#define PACKAGE_STRING ""
#define PACKAGE_BUGREPORT ""
#define PACKAGE_URL ""
/* end confdefs.h.  */

/* Override any GCC internal prototype to avoid an error.
   Use char because int might match the return type of a GCC
   builtin and then its argument prototype would still apply.  */
#ifdef __cplusplus
extern "C"
#endif
char gzeof ();
int
main ()
{
return gzeof ();
  ;
  return 0;
}

and have it fail with

gcc conftest.c -lz

If so can you investigate the paths where libz is being sought

gcc -Wl,--verbose conftest.c -lz > conftest.log 2>&1
grep "libz.so" conftest.log

and compare these to where libz.so is found in the working environment. It is not, to my understanding, an issue about the library version, but rather how it  is installed and discovered by conda.

 

ADD REPLY
0
Entering edit mode

In case anyone else comes along here searching for an answer:

I've played around with this a bit. It turns out that the problem is not with zlib at all; requiring zlib=1.2.8 ends up meaning that you need r-base<=3.4.1=1. Installing ShortRead also works with no problems in r-base=3.4.1=2, which requires zlib=1.2.11. At some point after that, they introduced changes in r-base which break installing packages with external dependencies.

I filed an issue at Conda-Forge with my findings.

ADD REPLY
1
Entering edit mode
@brendanfurneaux-13009
Last seen 4.7 years ago

I believe that the problem lies with the configuration of autotools in r-base>3.4.1b2, but I'm not competent to fix that. The plus side is that, although configure can't find zlib during the pre-installation, zlib is actually present in any Conda environment with r-base and can be linked during the actual installation. As I said in a comment above, I filed an issue at Conda-Forge. In the meantime, I made a fork of ShortRead which skips the check. It works for me with r-base=3.5.1.

tldr: remotes::install_github("brendanf/ShortRead")

ADD COMMENT
0
Entering edit mode

Thank you for this, it was very helpful and worked wonderfully (I'm also using r-base=3.5.1). I'm glad I looked at the thread gain, two days ago, when I bumped into this issue, you had not shared your solution!

ADD REPLY
1
Entering edit mode
@january-weiner-4252
Last seen 5.5 years ago
European Union

It is sufficient to set the compilers -L flag to point to the conda's library. If you downloaded the ShortRead package to, say, ShortRead_1.38.0.tar.gz, your conda environment is called myconda and your conda installation is in /your/conda/directory/, then it is sufficient to run

conda activate myconda
export LDFLAGS="-L/your/conda/directory/envs/myconda/lib/"
R CMD INSTALL ShortRead_1.38.0.tar.gz
ADD COMMENT
0
Entering edit mode

Thans, it works!

Or we can still use following command after setting LDFLAGS:

> library(BiocManager)
> BiocManager::install("ShortRead")

This is my R and bioconductor version:

> BiocManager::install()
Bioconductor version 3.8 (BiocManager 1.30.4), R 3.5.1 (2018-07-02)
ADD REPLY
0
Entering edit mode
@panditaridaman-12995
Last seen 6.4 years ago

I had the same error for the past week. I made it to work by installing ShortRead in R (not in conda) and then add the core R's library when I ran R in conda environment. I just made it to work, so I am sure there might be a better solution. I think this is because of conflict in the zlib conda and core library.

Also posted the solution for the same question here:
https://stackoverflow.com/questions/51017495/zlib-not-found-when-installing-shortread/51042014#51042014

 

ADD COMMENT

Login before adding your answer.

Traffic: 481 users visited in the last hour
Help About
FAQ
Access RSS
API
Stats

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.

Powered by the version 2.3.6