Static linking with a custom glibc version

Szabolcs Nagy szabolcs.nagy@arm.com
Thu Jun 4 13:05:59 GMT 2020


The 06/04/2020 12:21, Mahmood Naderan wrote:
> >this will link with the host libc crt files not the custom
> >libc ones. You need some combination of -B --sysroot -isystem
> >to static link with the custom libc.
> >
> >you also dont need to use rpath and dynamic-linker options,
> >those are for dynamic linking only (and likely same for>
> >emit-relocs)>
> >
> >so no, your build command is not correct.
> 
> gcc -o test.static -Wl,--emit-relocs -static -B /opt/glibc-2.23-install/lib --sysroot -isystem test.o

both --sysroot and -isystem require a path argument.
and -isystem is compile time flag, not link time flag.
i don't know how the glibc was installed or what
--prefix it was configured with so i cannot help
with the details.

you can use strace -f on the gcc command to see
what files are accessed/opened to see if all libc
objects come from the custom libc path.


More information about the Libc-help mailing list