Open timarnold opened 5 years ago
I'm still curious to learn how this works (and why these symbols weren't being found), but I do think I've solved my underlying problem by rebuilding the library in question rather than using this provided prebuilt library that was causing me issues.
👋 Alpine Linux uses the musl C library as its libc implementation. I suspect you had the libc6-compat
package installed. That's part of the reason for the elements you've observed.
You can see more about how the musl
packages are built here: https://git.alpinelinux.org/aports/tree/main/musl/APKBUILD?h=master
This package installs the libc.so*
files to /usr/glibc-compat/lib/
.
e.g.
# ls -l /usr/glibc-compat/lib/libc*
-rwxr-xr-x 1 root root 1816304 Feb 11 19:28 /usr/glibc-compat/lib/libc-2.29.so
-rw-r--r-- 1 root root 294 Feb 10 17:26 /usr/glibc-compat/lib/libc.so
lrwxrwxrwx 1 root root 12 Mar 18 02:04 /usr/glibc-compat/lib/libc.so.6 -> libc-2.29.so
I'm trying to install a C NATS client (https://libraries.io/github/nats-io/cnats) on my Alpine Linux Docker image. One of their libraries (https://github.com/nats-io/nats.c/blob/master/pbuf/lib/linux/libprotobuf-c.so) links to
libc.so.6
, and so I followed the instructions for this project to installglibc
.Once I follow the instructions, I still get linker errors. Random facts that may be helpful:
I see
libc.so.6
in/usr/lib/libc.so.6
(though it simply seems to be a symbolic link to/lib/ld-musl-x86_64.so.1
- is this expected?)Running
ldd /path/to/libprotobuf-c.so
shows me:It seems curious to me that
libc.so.6
points toldd
instead of, say,/usr/lib/libc.so.6
. Is this weird?nm -g /path/to/libprotobuf-c.so
yields (excluded irrelevant bits):and these symbols are the ones I get "undefined reference to" when I try to build.
When I run
objdump -TC /usr/lib/libc.so.6
and search for these symbols, I see symbols likememset
,strcmp
, etc., but they don't have the@@GLIBC_
bits. After some searching it seems these are called "version tags" (https://stackoverflow.com/a/41093059/1148702). When Iobjdump -TC /my/path/to/libc.so.6
on my Ubuntu machine (not Docker), I do see these version tags, so I'm thinking my linker errors have something to do with them being missing on my Alpine Docker build.Can anyone point me in the right direction?