Skip to content

Invalid libary include path generated in pkg-config file #4488

@tothambrus11

Description

@tothambrus11

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:

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

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions