Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to build zlib for arm64

I use an open-source rendering library (Ogre3D) which has a dependency on zlib.

In XCode5, I noticed that when building for iOS, zlib will not build if 64-bit (arm64) architecture is indicated by ARCHS setting.

I get errors about "implicit function declaration" relating to LSEEK macro, read and write functions. I looked up LSEEK in gzlib.c:

#if defined(_WIN32) && !defined(__BORLANDC__)
#  define LSEEK _lseeki64
#else
#if defined(_LARGEFILE64_SOURCE) && _LFS64_LARGEFILE-0
#  define LSEEK lseek64
#else
#  define LSEEK lseek
#endif
#endif

My guess is something here is wrong, but I don't know what. And as for read() and write() I have no clue.

like image 712
Mr. Boy Avatar asked Mar 06 '14 14:03

Mr. Boy


2 Answers

Try adding an #include <unistd.h> in gzguts.h.

like image 86
Mark Adler Avatar answered Sep 30 '22 08:09

Mark Adler


The easiest solution in that scenario is not to build zlib yourself at all, since it already comes pre-compiled with the iOS SDK (also for arm64).

This latest commit fixes it also in the official Ogre dependencies repository.

Apart from that, there is this other option from this Ogre3D thread:

With ARCHS = ARCHS_STANDARD_INCLUDING_64_BIT, projects like zlip were failing. When I changed this to ARCHS_STANDARD_32_64_BIT, they built OK. I've discovered the former evaluates to "armv7 armv7s arm64" while the latter currently evaluates to "armv7 armv7s". So I think zlip won't build for arm64.

That would mean that Ogre3D parts are compiled for 64-bit, where as some dependencies such as zlib stay 32-bit.

like image 40
Philip Allgaier Avatar answered Sep 30 '22 08:09

Philip Allgaier