zstd icon indicating copy to clipboard operation
zstd copied to clipboard

Invalid libary include path generated in pkg-config file

Open tothambrus11 opened this issue 3 months ago • 2 comments

Describe the bug I installed zstd on Ubuntu (in WSL). The library file is in /usr/lib/x86_64-linux-gnu/libzstd.so.1.5.5 and the pkg-config file is in /usr/lib/x86_64-linux-gnu/pkgconfig/libzstd.pc.

However, the contents of the libzstd.pc doesn't include the architecture-specific folder in the -L flag:

prefix=/usr
exec_prefix=${prefix}
includedir=${prefix}/include
libdir=${exec_prefix}/lib

Name: zstd
Description: fast lossless compression algorithm library
URL: https://facebook.github.io/zstd/
Version: 1.5.5
Libs: -L${libdir} -lzstd
Libs.private: -pthread
Cflags: -I${includedir}

This results in workarounds needed by external projects such as this:

# We need to be resilient to no libzstd being found by pkg-config, as it is apparently not on linux.
zstd_dash_L="$(pkg-config --silence-errors --libs-only-L libzstd || true)"
if ! (llvm-config > /dev/null 2>&1); then
  if [[ "$OSTYPE" == "linux-gnu"* || "$OSTYPE" == "cygwin" || "$OSTYPE" == "freebsd"* ]]; then
    export LD_LIBRARY_PATH="${zstd_dash_L#-L}:$LD_LIBRARY_PATH"
  elif [[ "$OSTYPE" == "darwin"* ]]; then
    export DYLD_LIBRARY_PATH="${zstd_dash_L#-L}:$DYLD_LIBRARY_PATH"
  elif [[ "$OSTYPE" == "msys" || "$OSTYPE" == "win32" ]]; then
    export PATH="${zstd_dash_L#-L}:$PATH"
  fi
fi

I would expect the Libs -L to point to the architecture-specific subfolder.

Relevant issue:

  • https://github.com/facebook/zstd/issues/927

To my understanding, this is where the pkg-config file is generated: https://github.com/facebook/zstd/blob/dev/build/cmake/lib/CMakeLists.txt#L262

Desktop WSL Ubuntu 24.04

tothambrus11 avatar Sep 20 '25 08:09 tothambrus11

Given that the files are installed in /usr/, and not in /usr/local/, I presume it means zstd was installed from package, not from source ?

Cyan4973 avatar Sep 20 '25 14:09 Cyan4973

I presume it means zstd was installed from package, not from source ?

Do they set prefix when compiling a binary?

tansy avatar Sep 22 '25 14:09 tansy