facebook / facebook/zstd

Invalid libary include path generated in pkg-config file

Open
#4,488 2 comments 0 reactions 1 assignee Claimed by @Cyan4973 View on GitHub
Install issues packaging issue
Dominant language
C
Stars
27.9k
Forks
2.6k
Avg merge
1d 3h
Merged PRs (30d)
8

Description

**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](https://github.com/hylo-lang/hylo/blob/ec1fd5a255946b128cfd26dc50ca5c5fc9adda3d/.devcontainer/make-pkgconfig.sh#L5C15-L5C63):
```
# 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

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.