0

I am currently working on building Glib version 2.45.8 on CentOS 7 running on x86-64 targeting a custom distro based off Linux from Scratch running on x86-64. There is a problem linking with libffi which is version 3.2.1.

path/to/build/directory/bin/ld: warning: libc.so.6, needed by //lib/../libffi.so, not found (try using -rpath or -rpath-link)
path/to/build/directory/lib64/libffi.so: undefined reference to `free@GLIBC_2.2.5'
path/to/build/directory/lib64/libffi.so: undefined reference to `mkostemp@GLIBC_2.7'
(etc ... there are about 15 undefined references total)
path/to/build/directory/lib64/libffi.so: undefined reference to `__getdelim@GLIBC_2.2.5'
path/to/build/directory/lib64/libffi.so: undefined reference to `getenv@GLIBC_2.2.5'

Using -rpath or -rpath-link will not work because the libc.so.6 file does not exist anywhere in the file system for my build.

However I do have libc.so and libc.so.0 in path/to/build/directory/lib64/ the directory in which libc.so.6 cannot be found.

Here are my ./configure and make commmands.

glib_cv_stack_grows=no \
glib_cv_uscore=no \
ac_cv_func_posix_getpwuid_r=yes \
ac_cv_func_posix_getgrgid_r=yes \
LIBFFI_CFLAGS=-lffi \
LIBFFI_LIBS=-lffi \
ZLIB_CFLAGS=-lz \
ZLIB_LIBS=-lz \
PKG_CONFIG_LIBDIR=$TARG/lib/pkgconfig \
./configure --prefix=/ --host=x86_64-linux --with-libiconv

make -j32 LDFLAGS=-liconv

How do I get the correct libc.so to be built?

TheArcticWalrus
  • 138
  • 3
  • 11
  • 2
    How do you have a Linux system without the standard C library?! – Thomas Feb 10 '20 at 15:27
  • Yeah, one sec I cleared out some part of the path to clarify. My system itself has libc.so.6 I will edit the question – TheArcticWalrus Feb 10 '20 at 15:29
  • 1
    @TheArcticWalrus : Please edit your question to include name / version / architecture of both the target OS and the host OS. – Knud Larsen Feb 10 '20 at 15:31
  • CentOS 7 has libffi-3.0.13 . Seems the alien libffi-3.2.1 is incompatible with CentOS 7. ..... Please note that **glibc** : `lib64/libc.so.6` *is* your OS (together with the kernnel) and cannot be changed. – Knud Larsen Feb 10 '20 at 16:02
  • @knud-larsen That is strange because when the same script is used to cross compile for arm libffi seems to be find. I just noticed that we are using uclibc instead of glibc could the missing references be due to the fact that those are simply non existent in uclibc? – TheArcticWalrus Feb 10 '20 at 16:12
  • 1
    It's plausible. Glibc does more than required of a libc implementation. – Christian Gibbons Feb 10 '20 at 16:47

1 Answers1

0

There we several things that had to be done to solve this problem. The first thing I found out was that if software has a dependancy on libc.so.6 it was built against glibc. However our toolchain for this build is using uClibc instead, which does not produce libc.so.6 when it is built. The solution was to write the LIBFFI and ZLIB clags and libs to link to the libffi and zlib built with uClibc.

glib_cv_stack_grows=no \
glib_cv_uscore=no \
ac_cv_func_posix_getpwuid_r=yes \
ac_cv_func_posix_getgrgid_r=yes \
ZLIB_CFLAGS=-I$TARG/include \
ZLIB_LIBS="-L$TARG/lib -lz" \
LIBFFI_CFLAGS=-I$TARG/include \
LIBFFI_LIBS="$TARG/lib/libffi.a" \
PKG_CONFIG_LIBDIR=$TARG/lib/pkgconfig \
./configure --prefix=/ --host=x86_64-linux --with-libiconv

make -j32 LDFLAGS=-liconv
TheArcticWalrus
  • 138
  • 3
  • 11