5

I'm trying to compile minimap2(in this repo https://github.com/lh3/minimap2.git) from source under a conda environment, The c compilers are also installed by conda. And it failed to link with zlib:

<conda_path>/bin/../lib/gcc/x86_64-conda_cos6-linux-gnu/7.3.0/../../../../x86_64-conda_cos6-linux-gnu/bin/ld: cannot find -lz
collect2: error: ld returned 1 exit status

This error can be reproduced by simply running "<conda_path>/bin/x86_64-conda_cos6-linux-gnu-cc -lz"

but if running "ld -lz --verbose" it works

$ which ld
/usr/bin/ld
$ ld -lz --verbose
(sth not useful)
===
attempt to open //usr/x86_64-redhat-linux/lib64/libz.so failed
attempt to open //usr/x86_64-redhat-linux/lib64/libz.a failed
attempt to open //usr/lib64/libz.so succeeded
-lz (//usr/lib64/libz.so)
libc.so.6 needed by //usr/lib64/libz.so
found libc.so.6 at /usr/lib64//libc.so.6
ld-linux-x86-64.so.2 needed by /usr/lib64//libc.so.6
found ld-linux-x86-64.so.2 at /usr/lib64//ld-linux-x86-64.so.2
ld: warning: cannot find entry symbol _start; not setting start address

I've add /usr/lib64/ to LIBRARY_PATH and LD_LIBRARY_PATH and nothing changed, so how to solve this? any help would be appreciated

Peter Wu
  • 193
  • 6
  • What's the original command you're running? – tadman Dec 04 '20 at 03:27
  • @tadman make from this git repo https://github.com/lh3/minimap2.git – Peter Wu Dec 04 '20 at 03:28
  • Please edit your question to include the command being run. You're going to have to do a bit of work to narrow down the problem to a specific issue. – tadman Dec 04 '20 at 03:29
  • How did you install the Conda compiler(s)? Using the Conda Forge compilers, either individually (e.g., `cxx-compiler`) or through the `compilers` metapackage (C, C++, FORTRAN), it automatically configures the `LD_LIBRARY_PATH` when activating. Perhaps [this answer](https://stackoverflow.com/a/64253999/570918) or [this answer](https://stackoverflow.com/a/62525834/570918) is useful. Otherwise, installing `gcc` or `clang` directly from Anaconda Cloud has always been a configuration headache, in my experience. – merv Dec 04 '20 at 23:08
  • Also, do you really need to compile from source? `minimap2` is available through Bioconda (e.g., `conda install -c conda-forge -c bioconda minimap2`). Otherwise, you should have a look at [the corresponding Bioconda recipe](https://github.com/bioconda/bioconda-recipes/tree/master/recipes/minimap2), which should demonstrate exactly how to compile it in a Conda environment using the Conda Forge compilers I referenced. – merv Dec 04 '20 at 23:14

1 Answers1

1

I have the similar problem and the following can fix it:

Quick Workaround

cd /path/to/your/conda/env/compiler_compat/ && mv ld ld.bak
# or just remove it if you don't care.

Recommended?

conda install -c conda-forge ld_impl_linux-64  # Modify the suffix to correspond with your platform
link89
  • 1,064
  • 10
  • 13