0

I've got errors when tried to build Zlib in chapter 8.4 CLFS for embedded: CLFS

Messages from a terminal:

CFLAGS="-Os" ./configure --shared --libdir=$CLFS/targetfs/lib64

Checking for shared library support...
No shared library support; try without defining CC and CFLAGS
Building static library libz.a version 1.2.13 with aarch64-linux-gnu-gcc --sysroot=/home/opi3-lts/targetfs.
Checking for size_t... Yes.
Checking for off64_t... Yes.
Checking for fseeko... Yes.
Checking for strerror... No.
Checking for unistd.h... Yes.
Checking for stdarg.h... Yes.
Checking whether to use vs[n]printf() or s[n]printf()... using vs[n]printf().
Checking for vsnprintf() in stdio.h... No.
  WARNING: vsnprintf() not found, falling back to vsprintf(). zlib
  can build but will be open to possible buffer-overflow security
  vulnerabilities.
Checking for return value of vsprintf()... Yes.
Checking for attribute(visibility) support... Yes.

When I'm trying make

aarch64-linux-gnu-gcc --sysroot=/home/opi3-lts/targetfs -Os -D_LARGEFILE64_SOURCE=1 -DNO_STRERROR -DNO_vsnprintf -DHAVE_HIDDEN  -c -o gzwrite.o gzwrite.c
aarch64-linux-gnu-ar rc libz.a adler32.o crc32.o deflate.o infback.o inffast.o inflate.o inftrees.o trees.o zutil.o compress.o uncompr.o gzclose.o gzlib.o gzread.o gzwrite.o 
aarch64-linux-gnu-gcc --sysroot=/home/opi3-lts/targetfs -Os -D_LARGEFILE64_SOURCE=1 -DNO_STRERROR -DNO_vsnprintf -DHAVE_HIDDEN -o example example.o  -L. libz.a

/home/opi3-lts/cross-tools/lib/gcc/aarch64-linux-gnu/12.2.0/../../../../aarch64-linux-gnu/bin/ld: cannot find /lib64/libc.so.6: No such file or directory
/home/opi3-lts/cross-tools/lib/gcc/aarch64-linux-gnu/12.2.0/../../../../aarch64-linux-gnu/bin/ld: cannot find /usr/lib64/libc_nonshared.a: No such file or directory
/home/opi3-lts/cross-tools/lib/gcc/aarch64-linux-gnu/12.2.0/../../../../aarch64-linux-gnu/bin/ld: cannot find /lib/ld-linux-aarch64.so.1: No such file or directory
collect2: error: ld returned 1 exit status
make: *** [Makefile:285: example] Error 1

I get it, that compiler trying to use library from the host system, but I export variables CC,CXX,LD with parameter --sysroot:

export CLFS_HOST="x86_64-cross-linux-gnu"
export CLFS_TARGET="aarch64-linux-gnu"
export CLFS_ARCH="aarch64"
export CLFS_ARM_ARCH="armv8-a"
export CLFS_FLOAT="hard"
export CLFS_FPU="vfpv4"
export CC="aarch64-linux-gnu-gcc --sysroot=/home/opi3-lts/targetfs"
export CXX="aarch64-linux-gnu-g++ --sysroot=/home/opi3-lts/targetfs"
export AR="aarch64-linux-gnu-ar"
export AS="aarch64-linux-gnu-as"
export LD="aarch64-linux-gnu-ld --sysroot=/home/opi3-lts/targetfs"
export RANLIB="aarch64-linux-gnu-ranlib"
export READELF="aarch64-linux-gnu-readelf"
export STRIP="aarch64-linux-gnu-strip"

I've tried make with next params:

CFLAGS="-Os" ./configure --shared --libdir=$CLFS/targetfs/lib64
make ARCH="${CLFA_ARCH}" CROSS_COMPILE="${CLFS_TARGET}-"`

and it didn't get me fine result

  • You don't seem to set `prefix`, however it seems that it used to [find](https://github.com/madler/zlib/blob/50893291621658f355bc5b4d450a8d06a563053d/configure#L62) the correct include and library folders. Try adding `--prefix=${CLFS}/cross-tools/${CLFS_TARGET}` or something similar to to your configure command, and see what happens. – skandigraun Jun 16 '23 at 10:17
  • I've tried to add the prefix, but automake zlib doesn't support this option. Maybe, I made a mistakes on early steps, cause when I try set CC="$CLSF/bla-bla.../aarch64-linux-gnu-gcc" (I've seen, that used GCC from my host machine, not compiled myself) and without --sysroot, library is compiled successfully. So I decided to remake from more early steps with a little bit force attention. What I'll get as a result, I'll message here. – kriptonus Jun 16 '23 at 15:07

0 Answers0