- Sponsor
-
Notifications
You must be signed in to change notification settings - Fork 2.9k
How can I add rpath with $ORIGIN, @loader_path and @executable_path? #5827
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Before investigating further, I assume you quoted |
I am not executing zig in the shell. I run the zig command directly through posix_spawnp(). for g++, like this. /usr/bin/g++ -o build/linux/x86_64/release/test build/.objs/test/linux/x86_64/release/src/test.c.o -Lbuild/linux/x86_64/release -Wl,-rpath=$ORIGIN -s -L/usr/local/lib -L/usr/lib -lshared_library_c -m64 for zig, use /usr/bin/zig build-exe -Lbuild/linux/x86_64/release -rpath $ORIGIN --strip -L/usr/local/lib -L/usr/lib -ltestlib -target x86_64-linux-gnu --output-dir build/linux/x86_64/release --name test --object build/.objs/test/linux/x86_64/release/src/main.zig.o |
What do |
By default, the version will be appended to the so library file, causing the link to fail. e.g. I rename /usr/bin/zig build-exe -Lbuild/linux/x86_64/release -rpath '$ORIGIN' --strip -L/usr/local/lib -L/usr/lib -ltestlib -target x86_64-linux-gnu --output-dir build/linux/x86_64/release --name test --object build/.objs/test/linux/x86_64/release/src/main.zig.o
$ ./build/linux/x86_64/release/test
Segmentation fault It will load And $ ldd ./build/linux/x86_64/release/test
linux-vdso.so.1 => (0x00007ffd53bfe000)
libtestlib.so.0 => not found $ readelf --dynamic ./build/linux/x86_64/release/test
Dynamic section at offset 0x2910 contains 14 entries:
Tag Type Name/Value
0x000000000000001d (RUNPATH) Library runpath: [$ORIGIN]
0x0000000000000001 (NEEDED) Shared library: [libtestlib.so.0]
0x0000000000000015 (DEBUG) 0x0
0x0000000000000017 (JMPREL) 0x200288
0x0000000000000002 (PLTRELSZ) 24 (bytes)
0x0000000000000003 (PLTGOT) 0x2059f0
0x0000000000000014 (PLTREL) RELA
0x0000000000000006 (SYMTAB) 0x200200
0x000000000000000b (SYMENT) 24 (bytes)
0x0000000000000005 (STRTAB) 0x200264
0x000000000000000a (STRSZ) 29 (bytes)
0x000000006ffffef5 (GNU_HASH) 0x200230
0x0000000000000004 (HASH) 0x20024c
0x0000000000000000 (NULL) 0x0 |
I saw Maybe it's just the library file name problem. |
I don't think linux supports these things. Are they darwin-isms? |
I think that |
glibc's ld-linux (man ld-linux)
|
zig sends
Not a bug. |
The added path will lose the single quotation in the final output command. How can this be solved? |
I need add rpath with $ORIGIN for elf, @loader_path and @executable_path for macho.
But
zig build-exe -rpath $ORIGIN/@loader_path
does not work.The text was updated successfully, but these errors were encountered: