iphone compilation problems


#6

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.


#7

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


#8

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.


#9

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


#10

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]


#11

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.


#12

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.


#13

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


#14

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

#15

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?


#16

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


#17

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?


#18

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

David


#19

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

Thanks


#20

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


#21

Any luck finding that old iphone project?

If not, how should I go about starting a new iphone project? Should, I try to base it on the iphone_pview app in the Panda3D/panda/src/iphone folder?

BTW: I am a total newb to panda3d.


#22

Oops, sorry, I didn’t get a chance to look last night. I’ll check again. But let me reiterate: there is no ‘project’ in the XCode sense. All I ever had was a tree of source code, as checked out from CVS, and with embedded Makefiles as generated by ppremake.

In short, I don’t have anything that you don’t already have.

The iphone_pview app is the only app I ever built. I had been working by hacking the code I needed into that app. I believe I had written it to unpack and launch its application code from a Panda3D multifile (.mf) file; this was an early precursor to the modern .p3d system.

The modern design for a Python-based iphone project would be to write a standalone app that launches a p3d file. This would be very similar to the existing code in iphone_pview, but it would utilize the modern conventions for p3d files. I don’t expect a newcomer to Panda3D to have an easy time writing this code.

To write a C++ or Objective-C based iPhone project, though, you could start with iphone_pview and simply modify it to suit your needs, writing the application directly there. That would be much simpler.

For a Panda newcomer, it would probably be worthwhile to write the application first in the standard desktop environment, to learn the normal Panda conventions.

David


#23

I understand that the code that you have is not an Xcode project. I am just looking for the basic structure of a panda app that worked once on an iphone. So I would gladly accept anything that you have.

I will also try to work with the iphone_pview app.

I also understand that I would be writing in C++. My python skills are next to nil any way.

As far as the OS/X route goes, that was why I wanted to get the simulator platform moving along, so I can build my app using the simulator which should get me close to where I want to be.

I have everything compiled, I just need to be able to run something now.

Thanks for your help.


#24

How did this go?


#25

I’m trying to compile panda3d 1.8.0 for the iPhone, but when compiling dtool the error I get is:

make[1]: *** No rule to make target ../cppparser/Opt4-iPhone/libp3cppParser', needed byOpt4-iPhone/interrogate’. Stop.
make[1]: Leaving directory `/Users/bostjan/peskovnik/panda3d-1.8.0/dtool/src/interrogate’

Any ideas what might be wrong?
I can post the Config.iPhone.pp if needed.