how to link with old versions of glibc?
Tue May 26 13:33:02 GMT 2020
Dear Florian,
thank you for your answer (and Carlos and Szabolcs).
Using what you suggest I get:
zimmerma@tomate:/tmp/src-FixCRlibm$ GLIBC=/localdisk/zimmerma/glibc-2.28/build ./compile.sh toto.c
/usr/bin/ld: /usr/lib/gcc/x86_64-linux-gnu/9/../../../x86_64-linux-gnu/Scrt1.o: in function `_start':
(.text+0x12): undefined reference to `__libc_csu_fini'
/usr/bin/ld: (.text+0x19): undefined reference to `__libc_csu_init'
collect2: error: ld returned 1 exit status
where /localdisk/zimmerma/glibc-2.28/build is the build directory for glibc
2.28, and compile.sh is the following script (from Florian's answer):
zimmerma@tomate:/tmp/src-FixCRlibm$ cat compile.sh
#!/bin/bash
gcc \
-Wl,-rpath=${GLIBC}:\
${GLIBC}/math:\
${GLIBC}/elf:\
${GLIBC}/dlfcn:\
${GLIBC}/nss:\
${GLIBC}/nis:\
${GLIBC}/rt:\
${GLIBC}/resolv:\
${GLIBC}/crypt:\
${GLIBC}/nptl:\
${GLIBC}/dfp \
-L ${GLIBC} \
-L ${GLIBC}/math \
-L ${GLIBC}/elf \
-L ${GLIBC}/dlfcn \
-L ${GLIBC}/nss \
-L ${GLIBC}/nis \
-L ${GLIBC}/rt \
-L ${GLIBC}/resolv \
-L ${GLIBC}/crypt \
-L ${GLIBC}/nptl \
-L ${GLIBC}/dfp \
-Wl,--dynamic-linker=${GLIBC}/elf/ld.so $@
and toto.c is the following program:
zimmerma@tomate:/tmp/src-FixCRlibm$ cat toto.c
#include <stdio.h>
#include <gnu/libc-version.h>
int main()
{
printf("GNU libc version: %s\n", gnu_get_libc_version ());
printf("GNU libc release: %s\n", gnu_get_libc_release ());
}
Best regards,
Paul
> From: Florian Weimer <fweimer@redhat.com>
> Date: Wed, 20 May 2020 16:50:58 +0200
>
> * Paul Zimmermann:
>
> > Dear Florian,
> >
> > thank you for your answer. In fact any solution that works (statically or
> > dynamically) is fine for my application.
>
> See the instructions here:
>
> <https://sourceware.org/glibc/wiki/Testing/Builds#Compile_against_glibc_build_tree>
>
> I'm not sure if this actually works, I would have expected some -L
> arguments as well, so maybe this:
>
> gcc \
> -Wl,-rpath=${GLIBC}:\
> ${GLIBC}/math:\
> ${GLIBC}/elf:\
> ${GLIBC}/dlfcn:\
> ${GLIBC}/nss:\
> ${GLIBC}/nis:\
> ${GLIBC}/rt:\
> ${GLIBC}/resolv:\
> ${GLIBC}/crypt:\
> ${GLIBC}/nptl:\
> ${GLIBC}/dfp \
> -L ${GLIBC} \
> -L ${GLIBC}/math \
> -L ${GLIBC}/elf \
> -L ${GLIBC}/dlfcn \
> -L ${GLIBC}/nss \
> -L ${GLIBC}/nis \
> -L ${GLIBC}/rt \
> -L ${GLIBC}/resolv \
> -L ${GLIBC}/crypt \
> -L ${GLIBC}/nptl \
> -L ${GLIBC}/dfp \
> -Wl,--dynamic-linker=${GLIBC}/elf/ld.so \
> …
>
> Does this help?
>
> Thanks,
> Florian
>
>
More information about the Libc-help
mailing list