vendredi 24 octobre 2008

Universal library for iPhone and Mac (or iPhone simulator)

use lipo tool to create from n architectures libraries a universal library:
/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/lipo -create libcurl-iphone.a libcurl.a -output libcurl-universal.a 
this will create a file called libcurl-universal.a which can be linked against an iPhone executable or a Mac executable.
Of course it works with all architectures (ppc, 32/64 bits, etc...)

libcurl on iPhone

In Terminal:
- export CC=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/arm-apple-darwin9-gcc-4.0.1
- export CFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk"
- export LDFLAGS="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk -Wl,-syslibroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk"
- export CPP=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp
-./configure --host=arm-apple-darwin9 --disable-shared --without-ssl --without-ldap --without-libssh2 --disable-ldap
then modify config.h and comment #define HAVE_STRERROR_R 1
- make
should compile with curl-7.19.0

jeudi 23 octobre 2008

stlport on iPhone

Here is how i've compiled stlport 5.1.6 for iPhone:
- Copied lib/Makefiles/gmake/darwin in lib/Makefiles/gmake/iphone
- Modify lib/Makefiles/gmake/gcc.mak to add iphone compilation support with those lines:
ifeq ($(OSNAME), iphone)
PATH:=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/:${PATH}
CXX=arm-apple-darwin9-gcc-4.0.1
CC=arm-apple-darwin9-gcc-4.0.1
OPT=-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk -Wl,-syslibroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk
CXX_VERSION := $(shell ${CXX} -dumpversion)
# TODO: ensure PANTHER's gcc compatibility...
CXX_VERSION_MAJOR := $(shell ${CXX} -dumpversion | awk 'BEGIN { FS = "."; } { print $1; }')
CXX_VERSION_MINOR := $(shell ${CXX} -dumpversion | awk 'BEGIN { FS = "."; } { print $2; }')
CXX_VERSION_PATCH := $(shell ${CXX} -dumpversion | awk 'BEGIN { FS = "."; } { print $3; }')
# This is to differentiate Apple-builded compiler from original
# compiler (it's has different behaviour)
ifneq ("$(shell ${CXX} -v 2>&1 | grep Apple)", "")
GCC_APPLE_CC := 1
endif

Then :
ifeq ($(OSNAME),iphone)
CCFLAGS = $(OPT)
CFLAGS = $(OPT)
ifndef STLP_BUILD_NO_THREAD
DEFS += -D_REENTRANT
endif
CXXFLAGS = -fexceptions $(OPT)
endif

And :
# Required for correct order of static objects dtors calls:
ifneq ($(OSNAME),cygming)
ifneq ($(OSNAME),windows)
ifneq ($(OSNAME),darwin)
ifneq ($(OSNAME),iphone)
ifneq ($(CXX_VERSION_MAJOR),2)
CXXFLAGS += -fuse-cxa-atexit
endif
endif
endif
endif
endif

- In build/lib run ./configure --target='iphone'; make -f gcc.mak install-release-static
- The lib should be in ./iphone-lib

That's should work without errors.

lundi 6 octobre 2008

OpenMAX and iPhone

ARM is providing library for OpenMAX optimized for ARM11 cpu.
You need RVDS 3.1 to compile it.

Cross Compile for iPhone (ffmpeg)

Configure commande line to Cross Compile ffmpeg for iPhone :
./configure --enable-cross-compile --cross-prefix=/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ --cc=arm-apple-darwin9-gcc-4.0.1 --prefix=/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk --extra-cflags="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk" --extra-ldflags="-isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk -Wl,-syslibroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS2.0.sdk" --disable-ffmpeg --disable-ffserver --disable-ffplay --arch=generic --enable-armv6 --disable-devices --enable-pthreads --disable-encoders --disable-muxers
Architecture is generic because arm does not compile (asm fail to compile).


I've made a little ffmpeg-opengl texture class to test movie as opengl texture. It works, slowly but it works.