Meson fails to link with a private dependency requirement
- Dominant language
- Python
- Stars
- 6.6k
- Forks
- 1.9k
- Avg merge
- 2d 6h
- Merged PRs (30d)
- 33
Description
I have created a test repository that shows the issue:
https://github.com/EmmanuelP/meson_issue/tree/e6c9565eb1283668014a721c0297df2c59e0203c
(Make sure to checkout the `private-issue` tag, I may push other changes to this repository)
* 3 projects, each installed in their own prefix, with dependencies managed using pkgconfig
* project_b library uses privately project_a library (Requires.private)
* project_c executable uses project_b library
-> project_c executables compilations, ld can't find project_a library.
A `build.sh` is provided to reproduce the project build steps. Here is the output:
```sh
The Meson build system
Version: 0.55.3
Source dir: /home/pacaud/Sources/meson-rpath-issue/project_a
Build dir: /home/pacaud/Sources/meson-rpath-issue/project_a/build
Build type: native build
Project name: project_a
Project version: 1.0
C compiler for the host machine: ccache cc (gcc 10.2.1 "cc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9)")
C linker for the host machine: cc ld.bfd 2.35-18
Host machine cpu family: x86_64
Host machine cpu: x86_64
Build targets in project: 1
Found ninja-1.10.2 at /usr/bin/ninja
[1/3] ccache cc -Ilibproject_a.so.1.0.p -I. -I.. -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -fPIC -MD -MQ libproject_a.so.1.0.p/lib_a.c.o -MF libproject_a.so.1.0.p/lib_a.c.o.d -o libproject_a.so.1.0.p/lib_a.c.o -c ../lib_a.c
[2/3] cc -o libproject_a.so.1.0 libproject_a.so.1.0.p/lib_a.c.o -Wl,--as-needed -Wl,--no-undefined -shared -fPIC -Wl,--start-group -Wl,-soname,libproject_a.so.1 -Wl,--end-group
[2/3] /usr/bin/meson install --no-rebuild
Installing libproject_a.so.1.0 to /home/pacaud/Sources/meson-rpath-issue/install_a/lib
Installing /home/pacaud/Sources/meson-rpath-issue/project_a/lib_a.h to /home/pacaud/Sources/meson-rpath-issue/install_a/include
Installing /home/pacaud/Sources/meson-rpath-issue/project_a/build/meson-private/project_a.pc to /home/pacaud/Sources/meson-rpath-issue/install_a/lib/pkgconfig
The Meson build system
Version: 0.55.3
Source dir: /home/pacaud/Sources/meson-rpath-issue/project_b
Build dir: /home/pacaud/Sources/meson-rpath-issue/project_b/build
Build type: native build
Using 'PKG_CONFIG_PATH' from environment with value: '/home/pacaud/Sources/meson-rpath-issue/install_a/lib/pkgconfig'
Using 'PKG_CONFIG_PATH' from environment with value: '/home/pacaud/Sources/meson-rpath-issue/install_a/lib/pkgconfig'
Project name: project_b
Project version: 1.0
C compiler for the host machine: ccache cc (gcc 10.2.1 "cc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9)")
C linker for the host machine: cc ld.bfd 2.35-18
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (1.7.3)
Using 'PKG_CONFIG_PATH' from environment with value: '/home/pacaud/Sources/meson-rpath-issue/install_a/lib/pkgconfig'
Run-time dependency project_a found: YES 1.0
Build targets in project: 1
Found ninja-1.10.2 at /usr/bin/ninja
[1/3] ccache cc -Ilibproject_b.so.1.0.p -I. -I.. -I/home/pacaud/Sources/meson-rpath-issue/install_a/include -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -fPIC -MD -MQ libproject_b.so.1.0.p/lib_b.c.o -MF libproject_b.so.1.0.p/lib_b.c.o.d -o libproject_b.so.1.0.p/lib_b.c.o -c ../lib_b.c
[2/3] cc -o libproject_b.so.1.0 libproject_b.so.1.0.p/lib_b.c.o -Wl,--as-needed -Wl,--no-undefined -shared -fPIC -Wl,--start-group -Wl,-soname,libproject_b.so.1 /home/pacaud/Sources/meson-rpath-issue/install_a/lib/libproject_a.so -Wl,--end-group -Wl,-rpath,/home/pacaud/Sources/meson-rpath-issue/install_a/lib -Wl,-rpath-link,/home/pacaud/Sources/meson-rpath-issue/install_a/lib
[2/3] /usr/bin/meson install --no-rebuild
Installing libproject_b.so.1.0 to /home/pacaud/Sources/meson-rpath-issue/install_b/lib
Installing /home/pacaud/Sources/meson-rpath-issue/project_b/lib_b.h to /home/pacaud/Sources/meson-rpath-issue/install_b/include
Installing /home/pacaud/Sources/meson-rpath-issue/project_b/build/meson-private/project_b.pc to /home/pacaud/Sources/meson-rpath-issue/install_b/lib/pkgconfig
The Meson build system
Version: 0.55.3
Source dir: /home/pacaud/Sources/meson-rpath-issue/project_c
Build dir: /home/pacaud/Sources/meson-rpath-issue/project_c/build
Build type: native build
Using 'PKG_CONFIG_PATH' from environment with value: '/home/pacaud/Sources/meson-rpath-issue/install_a/lib/pkgconfig:/home/pacaud/Sources/meson-rpath-issue/install_b/lib/pkgconfig'
Using 'PKG_CONFIG_PATH' from environment with value: '/home/pacaud/Sources/meson-rpath-issue/install_a/lib/pkgconfig:/home/pacaud/Sources/meson-rpath-issue/install_b/lib/pkgconfig'
Project name: project_c
Project version: 1.0
C compiler for the host machine: ccache cc (gcc 10.2.1 "cc (GCC) 10.2.1 20201125 (Red Hat 10.2.1-9)")
C linker for the host machine: cc ld.bfd 2.35-18
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: /usr/bin/pkg-config (1.7.3)
Using 'PKG_CONFIG_PATH' from environment with value: '/home/pacaud/Sources/meson-rpath-issue/install_a/lib/pkgconfig:/home/pacaud/Sources/meson-rpath-issue/install_b/lib/pkgconfig'
Run-time dependency project_b found: YES 1.0
Build targets in project: 2
Found ninja-1.10.2 at /usr/bin/ninja
[1/6] ccache cc -Ilibproject_c.so.1.0.p -I. -I.. -I/home/pacaud/Sources/meson-rpath-issue/install_b/include -I/home/pacaud/Sources/meson-rpath-issue/install_a/include -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -fPIC -MD -MQ libproject_c.so.1.0.p/lib_c.c.o -MF libproject_c.so.1.0.p/lib_c.c.o.d -o libproject_c.so.1.0.p/lib_c.c.o -c ../lib_c.c
[2/6] ccache cc -Iproject_c.p -I. -I.. -I/home/pacaud/Sources/meson-rpath-issue/install_b/include -I/home/pacaud/Sources/meson-rpath-issue/install_a/include -fdiagnostics-color=always -pipe -D_FILE_OFFSET_BITS=64 -Wall -Winvalid-pch -g -MD -MQ project_c.p/main.c.o -MF project_c.p/main.c.o.d -o project_c.p/main.c.o -c ../main.c
[3/6] cc -o libproject_c.so.1.0 libproject_c.so.1.0.p/lib_c.c.o -Wl,--as-needed -Wl,--no-undefined -shared -fPIC -Wl,--start-group -Wl,-soname,libproject_c.so.1 /home/pacaud/Sources/meson-rpath-issue/install_b/lib/libproject_b.so -Wl,--end-group -Wl,-rpath,/home/pacaud/Sources/meson-rpath-issue/install_b/lib -Wl,-rpath-link,/home/pacaud/Sources/meson-rpath-issue/install_b/lib
[4/6] /usr/bin/meson --internal symbolextractor /home/pacaud/Sources/meson-rpath-issue/project_c/build libproject_c.so.1.0 libproject_c.so.1.0 libproject_c.so.1.0.p/libproject_c.so.1.0.symbols
[5/6] cc -o project_c project_c.p/main.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group libproject_c.so.1.0 /home/pacaud/Sources/meson-rpath-issue/install_b/lib/libproject_b.so -Wl,--end-group '-Wl,-rpath,$ORIGIN/:/home/pacaud/Sources/meson-rpath-issue/install_b/lib' -Wl,-rpath-link,/home/pacaud/Sources/meson-rpath-issue/project_c/build/ -Wl,-rpath-link,/home/pacaud/Sources/meson-rpath-issue/install_b/lib
FAILED: project_c
cc -o project_c project_c.p/main.c.o -Wl,--as-needed -Wl,--no-undefined -Wl,--start-group libproject_c.so.1.0 /home/pacaud/Sources/meson-rpath-issue/install_b/lib/libproject_b.so -Wl,--end-group '-Wl,-rpath,$ORIGIN/:/home/pacaud/Sources/meson-rpath-issue/install_b/lib' -Wl,-rpath-link,/home/pacaud/Sources/meson-rpath-issue/project_c/build/ -Wl,-rpath-link,/home/pacaud/Sources/meson-rpath-issue/install_b/lib
/usr/bin/ld: warning: libproject_a.so.1, needed by /home/pacaud/Sources/meson-rpath-issue/install_b/lib/libproject_b.so, not found (try using -rpath or -rpath-link)
/usr/bin/ld: /home/pacaud/Sources/meson-rpath-issue/install_b/lib/libproject_b.so: undefined reference to `func_a'
collect2: error: ld returned 1 exit status
ninja: build stopped: subcommand failed
```
Contributor guide
Research direction
Start with the linked reproduction repository, check out the private-issue tag, and run build.sh to reproduce the failure across project_a, project_b, and project_c. Inspect the generated pkg-config metadata and final project_c link command. Done means project_c builds successfully when project_b privately depends on project_a.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- c
- Domain
- build-system
- Issue type
- Bug
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100