iphone compilation problems

I am interested in getting Panda running on iOS. I saw that there is another post where work was started on getting iOS working but was abandoned for a while. I tried what was mentioned and I got compilation started, but the compilation fails in the glstuff directory.

If someone can give me some info or guidance on how to get everything I need compiled. I would be happy to release my changes back to the community.

I was using the Panda1.7.0 source tarball since cvs was out last weekend.

The contents of my Config.pp looks like this:

#define BUILD_IPHONE iPhoneOS
#define IOS_DEV_ROOT Developer
#define HAVE_GLES2 1
#define GLES2_LIBS 1
#define LINK_AS_BUNDLE
#define LINK_ALL_STATIC 1

#define HAVE_OPENSSL
#define HAVE_WX

Hi, welcome to the forums!

The issues you had in glstuff were probably compilation issues with OpenGL ES. I have fixed several of them since 1.7.0 was released, so I advise getting the latest CVS source (it’s back up again).

If you still run into errors using the latest CVS, please post the compilation errors here.

It’s trying to compile OpenGL ES 2 support, but it cannot locate the headers. Is there even GLES2 support available? If not, you should define HAVE_GLES2 to nothing in the Config.pp file.

drwr (who made the iPhone port) can probably reply in more detail, though.

I think it does exist. The from 3GS on it supports gles2. Do you know where the include paths are generated?

The libraries and include paths are specified in Config.pp:

// Is OpenGL ES 1.x installed, and where? This is a minimal subset of
// OpenGL for mobile devices.
#define GLES_IPATH
#define GLES_LPATH
#define GLES_LIBS GLES_cm
#defer HAVE_GLES $[libtest $[GLES_LPATH],$[GLES_LIBS]]

// OpenGL ES 2.x is a version of OpenGL ES but without fixed-function
// pipeline - everything is programmable there.
#define GLES2_IPATH
#define GLES2_LPATH
#define GLES2_LIBS GLESv2
#defer HAVE_GLES2 $[libtest $[GLES2_LPATH],$[GLES2_LIBS]]

As for specifying the framework, you can simply override the GLES_LIBS to the empty string, override HAVE_GLES to be 1 and add this line in panda/src/glesgsg/:

#define OSX_SYS_FRAMEWORKS OpenGLES

And repeat the process similarly for GLES2 / gles2gsg.

But make sure you don’t mix-and-match OpenGL ES with OpenGL ES 2. Unless the same framework handles both OpenGL ES and OpenGL ES 2?
Is there an OpenGLES2 framework?

Anyway, this is all just guesswork, so I could be totally wrong.

Also, to support OpenGL ES 2, you’ll need to make various changes to panda/src/iphonedisplay, for instance you’ll need to edit it to request a GLES2 context instead of GLES1.

But unless you feel like writing a shader for every bit of geometry, I recommend just compiling with HAVE_GLES2 set to nothing and compiling with just OpenGL ES 1 for now.

The headers are within the same framework called OpenGLES. They are found in
OpenGLES.framework/Headers/ES1 and OpenGLES.framework/Headers/ES2.

so from the earlier compilation error would theoretically be fixed with

#import <OpenGLES/ES1/gl.h>
#import <OpenGLES/ES1/glext.h>

or

#import <OpenGLES/ES2/gl.h>
#import <OpenGLES/ES2/glext.h>

gles2gsg.h:44:23: error: GLES2/gl2.h: No such file or directory
gles2gsg.h:45:26: error: GLES2/gl2ext.h: No such file or directory

Ah! You should edit panda/src/gles2gsg/gles2gsg.h, and find these lines:

#include <GLES2/gl2.h>
#include <GLES2/gl2ext.h>

Replace it with:

#ifdef IS_OSX
  #include <OpenGLES/ES2/gl.h>
  #include <OpenGLES/ES2/glext.h>
#else
  #include <GLES2/gl2.h>
  #include <GLES2/gl2ext.h>
#endif

I’ve just committed this fix, too.

Sorry about creating that additional thread. I thought that I had hit reply.

Those changes made it compile. :smiley:

Just to have the thread complete. This is what my current Config.pp looks like:

#define BUILD_IPHONE iPhoneOS
#define IOS_SDK_VERSION 4.2
#define OSX_DEV_ROOT Developer

#define HAVE_GLES 1
#define GLES_LIBS

#define HAVE_GLES2 1
#define GLES2_LIBS
#define LINK_ALL_STATIC 1

#define HAVE_FREETYPE
#define HAVE_GL
#define HAVE_OPENSSL
#define HAVE_PYTHON
#define HAVE_TINYDISPLAY
#define HAVE_WX

================
Notes

#define IOS_SDK_VERSION 4.2 <- I added this to control the SDK_VERSION

#define OSX_DEV_ROOT Developer <- I added this because I have Xcode4 installed on my machine, plus developers may not always have Xcode located in /Developer.

I went ahead and enabled GLES1 also, that way I can drop down to GLES1 if necessary.

I also had to modify the PostConfig.pp file in Panda3D/dtool/pptempl to be this:

// This file is included after including all of $DTOOL/Config.pp and
// the user’s personal Config.pp file. It makes decisions necessary
// following the user’s Config settings.

#if [and [OSX_PLATFORM],[BUILD_IPHONE]] //#define IOS_PLATFORM iPhoneSimulator #define IOS_PLATFORM [BUILD_IPHONE]

#if [eq [IOS_PLATFORM], iPhoneOS]
#define ARCH_FLAGS -arch armv7 -mno-thumb
#define osflags -fpascal-strings -miphoneos-version-min=4.0
#define DEBUGFLAGS -gdwarf-2
#elif [eq [IOS_PLATFORM], iPhoneSimulator]
#define ARCH_FLAGS -arch i386
#define osflags -x objective-c -fmessage-length=0 -pipe -std=c99 -Wno-trigraphs -fpascal-strings -fasm-blocks -O0 -Wreturn-type -Wunused-variable -fexceptions -fvisibility=hidden -mmacosx-version-min=10.6 -gdwarf-2 -fobjc-abi-version=2 -fobjc-legacy-dispatch -D__IPHONE_OS_VERSION_MIN_REQUIRED=40200
#define DEBUGFLAGS -gdwarf-2 -DDEBUG
#else
#error Inappropriate value for BUILD_IPHONE.
#endif

#define xcode [OSX_DEV_ROOT] #define dev /[xcode]/Platforms/[IOS_PLATFORM].platform/Developer #define env env MACOSX_DEPLOYMENT_TARGET=10.6 PATH="[dev]/usr/bin:/[xcode]/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" #define CC [env] [dev]/usr/bin/gcc #define CXX [env] [dev]/usr/bin/g++ #define OSX_CDEFS __IPHONE_OS_VERSION_MIN_REQUIRED=40000 #define OSX_CFLAGS -isysroot [dev]/SDKs/[IOS_PLATFORM][IOS_SDK_VERSION].sdk $[osflags]

#defer ODIR_SUFFIX -$[IOS_PLATFORM]

#endif

A couple more questions: Is there a way to change the output directory for the simulator builds? :question:

I want to be able to specify something like /usr/local/panda3d/$[IOS_PLATFORM]/include /lib

That way I can change the Xcode config to look in the right place depending on the build type.

Additionally, I would like the ability to do fatbinaries, How can I make it build for two different architectures?

Let me know if you want the PostConfig.pp, in patch format. If so, would you send the command to generate a patch file against cvs.

Thanks for the help

Latest error. This time it is in the simulator environment.

env MACOSX_DEPLOYMENT_TARGET=10.6 PATH="/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++ -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -fpascal-strings -fasm-blocks -miphoneos-version-min=4.0 -o Opt3-OSX-iPhoneSimulator/interrogate Opt3-OSX-iPhoneSimulator/interrogate_interrogate_composite1.o Opt3-OSX-iPhoneSimulator/interrogate_interrogate_composite2.o -L…/cppparser/Opt3-OSX-iPhoneSimulator -L…/dconfig/Opt3-OSX-iPhoneSimulator -L…/dtoolbase/Opt3-OSX-iPhoneSimulator -L…/dtoolutil/Opt3-OSX-iPhoneSimulator -L…/interrogatedb/Opt3-OSX-iPhoneSimulator -L…/prc/Opt3-OSX-iPhoneSimulator -L…/pystub/Opt3-OSX-iPhoneSimulator -L/usr/local/panda/lib -lcppParser -linterrogatedb -ldconfig -ldtoolutil -ldtoolbase -lpystub -ldtoolutil -ldtoolbase -ldconfig -ldtoolutil -ldtoolbase -ldtoolutil -ldtoolbase -lprc -ldtoolbase -ldtoolbase -ldtoolutil -ldtoolbase -framework Foundation
Undefined symbols:
“.objc_class_name_NSAutoreleasePool”, referenced from:
literal-pointer@__OBJC@__cls_refs@NSAutoreleasePool in libdtoolutil.a(dtoolutil_filename_assist.o)

ld: symbol(s) not found
collect2: ld returned 1 exit status
make[1]: *** [Opt3-OSX-iPhoneSimulator/interrogate] Error 1
make: *** [interrogate] Error 2

This is what my Config.pp looks like

//#define BUILD_IPHONE iPhoneOS
#define BUILD_IPHONE iPhoneSimulator
#define OSX_DEV_ROOT Developer
#define IOS_SDK_VERSION 4.2

#define HAVE_GLES2 1
#define GLES2_LIBS

#define HAVE_GLES 1
#define GLES_LIBS

#define LINK_ALL_STATIC 1

#define HAVE_FREETYPE
#define HAVE_GL
#define HAVE_OPENSSL
#define HAVE_PYTHON
#define HAVE_TINYDISPLAY
#define HAVE_WX

This is my modified PostConfig.pp

// This file is included after including all of $DTOOL/Config.pp and
// the user’s personal Config.pp file. It makes decisions necessary
// following the user’s Config settings.

#if [and [OSX_PLATFORM],[BUILD_IPHONE]] //#define IOS_PLATFORM iPhoneSimulator #define IOS_PLATFORM [BUILD_IPHONE]

#if $[eq $[IOS_PLATFORM], iPhoneOS] 
	#define ARCH_FLAGS -arch armv7 -arch armv6 -mno-thumb 
	#define osflags -fpascal-strings -miphoneos-version-min=4.0 
	#define DEBUGFLAGS -gdwarf-2 
#elif $[eq $[IOS_PLATFORM], iPhoneSimulator] 
	#define ARCH_FLAGS -arch i386 
	#define osflags -fpascal-strings -fasm-blocks -miphoneos-version-min=4.0 
	#define DEBUGFLAGS -gdwarf-2 -DDEBUG
#else 
	#error Inappropriate value for BUILD_IPHONE. 
#endif 

#define xcode $[OSX_DEV_ROOT] 
#define dev /$[xcode]/Platforms/$[IOS_PLATFORM].platform/Developer 
#define env env MACOSX_DEPLOYMENT_TARGET=10.6 PATH="$[dev]/usr/bin:/$[xcode]/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" 
#define CC $[env] $[dev]/usr/bin/gcc 
#define CXX $[env] $[dev]/usr/bin/g++ 
#define OSX_CDEFS __IPHONE_OS_VERSION_MIN_REQUIRED=40000 
#define OSX_CFLAGS -isysroot $[dev]/SDKs/$[IOS_PLATFORM]$[IOS_SDK_VERSION].sdk $[osflags] 

#defer ODIR_SUFFIX -$[IOS_PLATFORM]

#endif [/b]

You can set the installation directory for ppremake by defining INSTALL_DIR to the appropriate location, like:

#defer INSTALL_DIR /usr/local/panda3d/$[IOS_PLATFORM]

Create fat binaries like this:

#define UNIVERSAL_BINARIES 1
#define ARCH_FLAGS -arch i386 -arch ppc

The “cvs diff” command generates a patch.

Keep in mind that it won’t use GLES2 unless you change this line in panda/src/iphonedisplay/eaglView.mm:

    context = [[EAGLContext alloc] initWithAPI:kEAGLRenderingAPIOpenGLES1];

Maybe we should make a configuration variable to change this, or so.

Thanks for the quick feedback. I figured out the arch thing before your reply, however the INSTALL_DIR was very helpful.

The latest is that it is trying to build the test_interrogate program even though I have this

#define HAVE_INTERROGATE

.

I figured out that I needed to add this to the top of dtool/src/test_interrogate/Sources.pp to turn it off. So you might want to change that in the repository.

#define BUILD_DIRECTORY $[HAVE_INTERROGATE]

Again thanks for all of the help so far.

Ah, thank you! I’ve just committed that.

I seem to be having problems where it is trying to build actual programs that run. The latest being check_adler_check_adler of the downloadertools directory I really don’t need those to build for iphone os or simulator. Is there a libraries only option?

For some reason it will build using iphoneos but not for iphonesimulator. This is the latest error.

env MACOSX_DEPLOYMENT_TARGET=10.6 PATH="/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin:/Developer/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin" /Developer/Platforms/iPhoneSimulator.platform/Developer/usr/bin/g++ -arch i386 -isysroot /Developer/Platforms/iPhoneSimulator.platform/Developer/SDKs/iPhoneSimulator4.2.sdk -fpascal-strings -fasm-blocks -miphoneos-version-min=4.0  -o Opt3-OSX-iPhoneSimulator/check_adler Opt3-OSX-iPhoneSimulator/check_adler_check_adler.o    -L../downloader/Opt3-OSX-iPhoneSimulator -L../express/Opt3-OSX-iPhoneSimulator -L../pandabase/Opt3-OSX-iPhoneSimulator -L/Users/gwatkins/iPhoneSimulator.platform/panda3d/lib -L/Users/gwatkins/iPhoneSimulator.platform/panda3d/lib -ldownloader -lexpress -lexpress -lpandabase -lpandabase -linterrogatedb -lprc -ldconfig -ldtoolutil -ldtoolbase -lpystub -lprc -lz  -framework Foundation
Undefined symbols:
  ".objc_class_name_NSAutoreleasePool", referenced from:
      literal-pointer@__OBJC@__cls_refs@NSAutoreleasePool in libdtoolutil.a(dtoolutil_filename_assist.o)
ld: symbol(s) not found

I don’t know if there is an easy way to disable all bin_target statements.

As for the linker issue - I don’t know. NSAutoreleasePool is supposed to be defined in Foundation.
I’ve googled for the issue, and I can find a lot of advices, most of which are all different.

Maybe you still have libraries on the linker path that you compiled against the iPhone itself, or using a different architecture, or so?

Hmm, there’s not (currently) a built-in way to disable bin_targets, but you could just do “make install-iphonedisplay” instead of “make install” to build only the targets directly needed in support of the iphonedisplay target.

David

I got the simulator to compile, I think with ios4.0 plus they went with the non-fragile abi. So these were the new compiler flags in dtool/pptempl/PostConfig.pp that I used just for the simulator build.

	#elif $[eq $[IOS_PLATFORM], iPhoneSimulator] 
		#define ARCH_FLAGS -arch i386 
		#define osflags -fpascal-strings -fasm-blocks -fmessage-length=0 -fobjc-abi-version=2 -fobjc-legacy-dispatch -fexceptions -fvisibility=hidden -pipe -Wno-trigraphs -O0 -Wreturn-type -Wunused-variable -DDEBUG -mmacosx-version-min=10.6
		#define DEBUGFLAGS -gdwarf-2 -DDEBUG
	#else 
		#error Inappropriate value for BUILD_IPHONE. 
	#endif 

I am not ready to send in the final version of that file yet, because I haven’t actually made an app run yet on either platform. Hopefully, I can get to that tonight.

Does anyone have an Xcode project that worked before?

I never used an XCode project; I did all of my compilations via command-line Make.

David

Do you still have that project around? I would like to build an xcode template based on it.

Thanks

I’ll check my computer at home tonight. But I wasn’t using anything that’s not already in the source tree: all of my makefiles were generated by ppremake.

David