Search
Question: Installing ShortRead - error: zlib not found even with zlib in LD_LIBRARY_PATH
2
gravatar for joseph.elsherbini
6 months ago by
joseph.elsherbini30 wrote:
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
ADD COMMENTlink modified 3 months ago by olavur10 • written 6 months ago by joseph.elsherbini30
1
gravatar for Martin Morgan
6 months ago by
Martin Morgan ♦♦ 22k
United States
Martin Morgan ♦♦ 22k wrote:

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 COMMENTlink modified 6 months ago • written 6 months ago by Martin Morgan ♦♦ 22k
1
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 REPLYlink written 6 months ago by joseph.elsherbini30

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 REPLYlink modified 6 months ago • written 6 months ago by Martin Morgan ♦♦ 22k

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 REPLYlink modified 4 months ago • written 4 months ago by amalthomas1110

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

ADD REPLYlink written 4 months ago by Martin Morgan ♦♦ 22k

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 REPLYlink modified 4 months ago • written 4 months ago by amalthomas1110

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 REPLYlink written 4 months ago by Till20
2

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 REPLYlink modified 4 months ago • written 4 months ago by Till20

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 REPLYlink written 4 months ago by Martin Morgan ♦♦ 22k

 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 REPLYlink modified 4 months ago • written 4 months ago by amalthomas1110

Just add those lines at configure:2889

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

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

ADD REPLYlink modified 3 months ago • written 3 months ago by adrien.foucal0

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 REPLYlink written 3 months ago by Martin Morgan ♦♦ 22k
1
gravatar for olavur
3 months ago by
olavur10
olavur10 wrote:

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 COMMENTlink modified 3 months ago • written 3 months ago by olavur10

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 REPLYlink modified 3 months ago • written 3 months ago by Martin Morgan ♦♦ 22k
0
gravatar for pandit.aridaman
4 months ago by
pandit.aridaman0 wrote:

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 COMMENTlink written 4 months ago by pandit.aridaman0
Please log in to add an answer.

Help
Access

Use of this site constitutes acceptance of our User Agreement and Privacy Policy.
Powered by Biostar version 2.2.0
Traffic: 361 users visited in the last hour