Home > Software engineering >  Crosscompiling zlib for arm64/aarch64
Crosscompiling zlib for arm64/aarch64

Time:11-06

I have to crosscompile zlib on my x86_64 Ubuntu system for Android arm64/aarch64 as I want to use it inside of an app. I got the zlib from the official website (version 1.2.13). Inside of the folder I execute

CHOST=arm64 ./configure

Which executes without errors and then I run make which results in an error

/usr/bin/ld: deflate.lo: relocation R_X86_64_PC32 against symbol `_length_code' can not be used when making a shared object; recompile with -fPIC
/usr/bin/ld: final link failed: bad value
collect2: error: ld returned 1 exit status
make: *** [Makefile:278: libz.so.1.2.13] Error 1

Building it for x86_64 works completely fine. Am I missing any flags here? Not sure if the recompile with -fPIC is actually the solution or just missing something.

CodePudding user response:

Thanks to Mark Adlers suggestion I found the solution. Despite the system found gcc, it is necessary to explicitly set gcc as compiler.

The solution is:

CC=gcc CHOST=arm64 ./configure
  • Related