1

I am trying to create a conda package that includes c code that have to compile with -lz. However, when the package is building, ld cannot find zlib even though I provide it with any paths possible.

As I understand, conda creates almost empty environment, and then fills it with necessary libraries and tools. It also installs zlib, so that there is zlib.h in $BUILD_PREFIX/include/ and libz.so, libz.a in $BUILD_PREFIX/lib.

Compilation itself looks like

$BUILD_PREFIX/bin/x86_64-conda_cos6-linux-gnu-cc -fPIC -g -Wall -O2 -Wc++-compat main.o -o <name> -L. -l<name> -lm -lz -lpthread

x86_64-conda_cos6-linux-gnu-cc is gcc version 7.3.0, and it calls ld defined here as $BUILD_PREFIX/bin/x86_64-conda_cos6-linux-gnu-ld. Then ld falls with an error cannot find -lz.

I tried using

export C_INCLUDE_PATH="$BUILD_PREFIX/include"
export LIBRARY_PATH="$BUILD_PREFIX/lib"
export LD_LIBRARY_PATH="$BUILD_PREFIX/lib"
export LD_PRELOAD="$BUILD_PREFIX/lib/libz.so"

in any combinations, but that did not work.

Are there any other ways to show ld path to the library?

  • 1
    These are all wrong. In particular, the `LD_*` ones are looked at during load time, not at link time. Pass the path via the `-L` option on the gcc command line (currently you have `-L.`, which tells gcc to tell the linker to look for libraries in the current working directory — in addition to normal system paths). – Vladislav Ivanishin Jul 19 '19 at 11:10
  • Please show the output of `cd $BUILD_PREFIX/lib && ls -l libz*`. – zwol Jul 19 '19 at 12:16
  • @zwol `libz.a` `libz.so -> libz.so.1.2.11` `libz.so.1 -> libz.so.1.2.11` `libz.so.1.2.11`. But the comment of @VladislavIvanishin helped – Timofey Prodanov Jul 19 '19 at 16:15

0 Answers0