7

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.

unixsmurf
  • 5,852
  • 1
  • 33
  • 40
Mr. Boy
  • 60,845
  • 93
  • 320
  • 589
  • We are using the official *zlib* library (version 1.2.8 as of yesterday), but we have a modified `CMakeList.txt` file, with many things stripped out. Perhaps compare ours to the one from the official *zlib* library to check if there are some mandatory things in order for it to compile on arm64 that we need to add. – Philip Allgaier Mar 06 '14 at 14:27
  • BY 'we' you mean Ogre3D, right? I didn't realise customized versions were used. – Mr. Boy Mar 06 '14 at 14:33
  • 1
    Yes, by '*we*' I mean Ogre3D (or more specifically the Ogre3D dev team I am part of). Should have made that clearer,sorry. Again: The source code is the official version, just the CMakeList.txt is different. – Philip Allgaier Mar 06 '14 at 14:36
  • Also: Did you try to manually define `_LARGEFILE64_SOURCE` and set `_LFS64_LARGEFILE-0` to check whether used `lseek64` would solve the issue? – Philip Allgaier Mar 06 '14 at 14:46

2 Answers2

12

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

Mark Adler
  • 101,978
  • 13
  • 118
  • 158
1

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.

Philip Allgaier
  • 3,505
  • 2
  • 26
  • 53
  • I think that's just describing the same problem... it doesn't build for arm64. While _not_ building for arm64 is an option, 32 bit apps introduce extra overhead on 64-bit iOS and it doesn't seem a long-term fix! – Mr. Boy Mar 06 '14 at 14:34
  • I see and concur. Have a look at this answer then. Maybe adding that `#include ` solves the issue: http://stackoverflow.com/a/20143790/1947205 – Philip Allgaier Mar 06 '14 at 14:39