Building autoconf-configured libraries for iPhone OS

In addition to GLU, another dependency for the iPhone app I've been working on is the Geospatial Data Abstraction Library (GDAL). Like most open-source software written in C/C++, the GDAL package uses autoconf and is built via the familiar "configure; make; make install" incantation. However, since Xcode doesn't provide much support for such packages, I had to figure out for myself how to build GDAL for iPhone OS.

It took a bit more work than I expected, but, through trial and error and some careful scrutiny of Xcode build logs, I eventually puzzled out the appropriate combination of compiler/linker flags and environment variables. And since I don't think anyone else should have to rediscover what I learned, I wrote a little shell script that automates the process.

To use the script, run it from the directory that contains your package's configure script. The one required argument is the target platform, which must be "device" or "simulator". Any arguments after the target will be passed to configure. Note that the script always passes --prefix, --host, --disable-shared, and --enable-static to configure, so you shouldn't specify any of those on the command line. (However, you can change the installation prefix with the -p option.) If configure succeeds, the script runs "make install". Finally, if all goes well, it prints a message saying where the files were installed.

For example, to compile and install GDAL for the device, I just run:

$ build_for_iphoneos device --without-pcraster --without-png ...

You can get more detailed usage info by passing the script the -h option.

By default, the script will install files in a subdirectory of $HOME/Developer/Platforms that mirrors the layout of /Developer/Platforms. For example, the installation prefix for a device build defaults to $HOME/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.1.sdk. The advantage of this is that you can make Xcode aware of the installed files for both the simulator and the device by adding the following under "All Configurations" in your project settings:

Header Search Paths $(HOME)/$(SDKROOT)/include
Library Search Paths $(HOME)/$(SDKROOT)/lib

Since the script builds your package as a static library, you'll also need to link against any other libraries it depends on, in addition to the library itself. For GDAL, I have to add "-lstdc++ -lz -lgdal" to the "Other Linker Flags" setting.

Hopefully, this will make life a little easier for anyone trying to use an autoconfed library in their iPhone app.

Tags: iphone
Mon, 29 Sep 2008 04:19 UTC

Announcing iGLU: OpenGL Utility Library for iPhone OS

Recently, while working on an OpenGL-based iPhone application, I found that I needed to use tessellation to transform some complex polygons into triangles. The OpenGL Utility Library (GLU) supports tessellation (via GLUtesselator). Unfortunately, iPhone OS doesn't include a GLU implementation.

After failing to find a standalone tessellation library that met my needs, I decided to take a look at the GLU implementation included with Mesa. The Mesa GLU is based on code from SGI's OpenGL Sample Implementation, and it turned out to be relatively easy to extract it from MesaLib. After some minor changes to the source and Makefiles, I succeeded in producing libGLU.a's for both the iPhone simulator and the device.

Since this may be of interest to other iPhone developers, I've packaged it up and released it as iGLU. Note that several GLU features (specifically, mipmapping, quadrics, and NURBS) are missing from iGLU, as their implementations depend on functionality that is absent in OpenGL ES 1.1. If someone wants to provide ES-compatible implementations of these features, I'd be happy to include them in iGLU, but I have neither the time nor the inclination to write them myself.

I hope some folks find this package useful. Please direct any questions, comments, or bug reports to the iphone-glu group.

Tags: iglu, iphone, opengl
Sun, 28 Sep 2008 22:57 UTC

Projects

Here's a list of free software projects I've written or worked on:

iGLU
OpenGL Utility Library (GLU) for iPhone OS
multitask
Cooperative multitasking and asynchronous I/O using Python generators
pybonjour
Pure-Python interface to Apple Bonjour and compatible DNS-SD libraries
Bonjour
I wrote some patches to support Windows Mobile/CE.
i2py
Convert IDL to Python
PySL
Use S-Lang from Python (and vice versa)
SLglade
S-Lang bindings for libglade

Tags: apple, bonjour, iphone, opengl, python, s-lang
Sat, 13 Sep 2008 14:53 UTC

Previous »