Among other problems, after updating and firing off an iOS build with my shiny new XCode5 tool, zlib no longer builds. It gives me errors about stuff not being supported in C99. I thought it might be along similar lines to how the C++11 compilers were causing problems, but changing the "C language dialect" doesn't seem to help.

Implicit declaration of function 'read' is invalid in C99

So is there a fix?

Updated at bottom, please read...

Last edited by simedj on Thu Mar 06, 2014 1:59 pm, edited 3 times in total.

Yes, I've had it all working with XCode 4 - and in fact earlier in the day it built with XCode 5 without these problems. From the other thread it seemed like my working copy was a bit out of date but still, it built OK. The whole point for me of putting Dependencies in Ogre source dir is that Ogre CMake picks it all up automagically.

I suppose it's just possible the manual DOGRE_BUILD_PLATFORM_APPLE_IOS:BOOL flag could've got lost on my main CMake setup (I added it using the GUI tool)... since I cleaned out my build dir. But I tried to avoid this and I thought the flag was set. Another thing to check... can you confirm you're building your own dependencies in XCode5 without these issues?

Update: This is just getting weird. I cleaned out my build-dir (again) and re-ran CMake (again); checking the APPLE_IOS flag is set. I get build/Ogre.xcodeproj which contains Ogre target as well as all the dependencies as separate targets. I also get build/Dependencies/OgreDeps.xcodeproj.

If I build target zlib in OgreDeps.xcodeproj, it succeeds with a few warnings:

/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzlib.c:250:24: Implicit declaration of function 'lseek' is invalid in C99/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzlib.c:14:17: Implicit declaration of function 'lseek' is invalid in C99/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzread.c/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzread.c:30:15: Implicit declaration of function 'read' is invalid in C99/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzread.c:586:11: Implicit declaration of function 'close' is invalid in C99/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzwrite.c/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzwrite.c:84:15: Implicit declaration of function 'write' is invalid in C99/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzwrite.c:561:9: Implicit declaration of function 'close' is invalid in C99

If I build target zlib in Ogre.xcodeproj, it fails with the same issues as both errors AND warnings (color-coded):

/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzlib.c:250:24: Implicit declaration of function 'lseek' is invalid in C99/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzlib.c:250:24: Implicit declaration of function 'lseek' is invalid in C99/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzread.c:30:15: Implicit declaration of function 'read' is invalid in C99/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzread.c:586:11: Implicit declaration of function 'close' is invalid in C99/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzread.c:30:15: Implicit declaration of function 'read' is invalid in C99/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzwrite.c:84:15: Implicit declaration of function 'write' is invalid in C99/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzwrite.c:561:9: Implicit declaration of function 'close' is invalid in C99/usr/local/ogre/ogre1.8/src/Dependencies/src/zlib/gzwrite.c:84:15: Implicit declaration of function 'write' is invalid in C99

I wanted to confirm this so I made sure XCode5 was set as default version, removed old 3.2.6 version, cleared the build-dir, and even updated CMake to newer version. Same result - the OgreDeps.xcodebuild version builds OK, the Ogre.xcodebuild version does not.

I wouldn't know where to start looking to see how the dependency projects get included as targets in the main Ogre project, but it seems some setting must be overriden/ignored - maybe if you're building dependencies separately that's why you haven't seen it?

I can see one setting is different - see screenshot - but I don't know these settings very well:

Well OgreDeps is a whole separate repo with its own CMake so presumably that's where OgreDeps.xcodeproj comes from. I've been told putting OgreDeps working/checkout dir inside Ogre/src working dir is OK before and it's always worked OK until now

Since the OgreDeps project is building with less problems, which CMake setting do I use in Ogre to stop it adding dependency targets to the Ogre project?

After fixing the architecture flag and the C++11 stuff in the generated Ogre.xcodeproj (the work of moments once you know) I'm actually only getting one issue remaining, which is in OgreGLSLESProgramManagerCommon.cpp (line 90):

kGlslTargetOpenGLES20 isn't recognised as a symbol... I am deliberately building with Cg support and GLSL optimiser ON. I thought I was doing so previously (I was definitely using Cg), do you know what this is about? I could just build without the GLSL optimiser if it's a problem.

So... I now have Ogre building (I disabled GLSL optimiser). I got my project to build too. In iOS6 simulator it works.

In iOS7 sim it still crashes - but now in a different place. Before it crashed in rendersystem code; that does not happen now, it's in Cg shader processing. Which I think is a separate problem so I'll let this thread draw to a slightly confused close

Just a little update for my own memory when I break my build in 6 months and find this thread - or for anyone else.

I had two problems, and I think I now know what they were.

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.

Other projects seemed to require to be build for C++98 not C++11. I've seen comments about this before; are Ogre and standard dependencies compatible with C++11 or should the CMake scripts explicitly set this for iOS?