kienjakenobi wrote:
At the moment, I am having difficulty compiling libpng. libpng does not appear to like Apple's custom stdio.h header file.
What errors are you getting? I'm pretty sure I've build this library before, although not for iOS. Building for iOS shouldn't be much different than any cross-platform build, such as when building 32-bit on a 64-bit machine.
I tried it myself and couldn't get the configure script to do it all. Those things never work when you need them to. I had to hack up the Makefile and libtool file. Here is a patch file:
diff -crB libpng-1.2.44/Makefile libpng-1.2.44.iOS/Makefile
* libpng-1.2.44/Makefile 2010-10-14 14:57:16.000000000 -0400
--- libpng-1.2.44.iOS/Makefile 2010-10-14 14:50:06.000000000 -0400
*************
* 171,180 **
AUTOHEADER = ${SHELL} /Users/jdaniel/Downloads/libpng-1.2.44/missing --run autoheader
AUTOMAKE = ${SHELL} /Users/jdaniel/Downloads/libpng-1.2.44/missing --run automake-1.11
AWK = awk
! CC = gcc
CCDEPMODE = depmode=gcc3
! CFLAGS = -g -O2
! CPP = gcc -E
CPPFLAGS =
CYGPATH_W = echo
DEFS = -DHAVECONFIGH
--- 171,180 ----
AUTOHEADER = ${SHELL} /Users/jdaniel/Downloads/libpng-1.2.44/missing --run autoheader
AUTOMAKE = ${SHELL} /Users/jdaniel/Downloads/libpng-1.2.44/missing --run automake-1.11
AWK = awk
! CC = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc
CCDEPMODE = depmode=gcc3
! CFLAGS = -g -O2 -isysroot /Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk -arch armv7
! CPP = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/cpp -E
CPPFLAGS =
CYGPATH_W = echo
DEFS = -DHAVECONFIGH
*************
* 194,200 **
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = ${INSTALL}
INSTALLSTRIPPROGRAM = $(install_sh) -c -s
! LD = /usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld
LDFLAGS =
LIBOBJS =
LIBPNG_DEFINES = -DPNGCONFIGURELIBPNG
--- 194,200 ----
INSTALL_PROGRAM = ${INSTALL}
INSTALL_SCRIPT = ${INSTALL}
INSTALLSTRIPPROGRAM = $(install_sh) -c -s
! LD = /Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ld
LDFLAGS =
LIBOBJS =
LIBPNG_DEFINES = -DPNGCONFIGURELIBPNG
diff -crB libpng-1.2.44/config.log libpng-1.2.44.iOS/config.log
* libpng-1.2.44/config.log 2010-10-14 14:57:16.000000000 -0400
--- libpng-1.2.44.iOS/config.log 2010-10-14 14:48:08.000000000 -0400
*************
* 30,37 **
Processor type: i486 (Intel 80486)
Processors active: 0 1
Primary memory available: 4.00 gigabytes
! Default processor set: 90 tasks, 370 threads, 2 processors
! Load average: 0.28, Mach factor: 1.71
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
--- 30,37 ----
Processor type: i486 (Intel 80486)
Processors active: 0 1
Primary memory available: 4.00 gigabytes
! Default processor set: 90 tasks, 374 threads, 2 processors
! Load average: 0.38, Mach factor: 1.60
/bin/machine = unknown
/usr/bin/oslevel = unknown
/bin/universe = unknown
diff -crB libpng-1.2.44/libtool libpng-1.2.44.iOS/libtool
* libpng-1.2.44/libtool 2010-10-14 14:57:16.000000000 -0400
--- libpng-1.2.44.iOS/libtool 2010-10-14 14:55:40.000000000 -0400
*************
* 240,249 **
hardcodeintolibs=no
# Compile-time system search path for libraries.
! syslib_search_path_spec="/usr/lib/gcc/i686-apple-darwin10/4.2.1/x8664 /usr/lib/i686-apple-darwin10/4.2.1 /usr/lib /usr/local/lib"
# Run-time system search path for libraries.
! syslib_dlsearch_pathspec="/usr/local/lib /lib /usr/lib"
# Whether dlopen is supported.
dlopen_support=unknown
--- 240,249 ----
hardcodeintolibs=no
# Compile-time system search path for libraries.
! syslib_search_pathspec="/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk/usr/lib"
# Run-time system search path for libraries.
! syslib_dlsearch_pathspec="/Developer/Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS3.2.sdk/usr/lib"
# Whether dlopen is supported.
dlopen_support=unknown
*************
* 260,272 **
# The linker used to build libraries.
! LD="/usr/libexec/gcc/i686-apple-darwin10/4.2.1/ld"
# Commands used to build an old-style archive.
oldarchivecmds="$AR $AR_FLAGS $oldlib$oldobjs~$RANLIB $oldlib"
# A language specific compiler.
! CC="gcc"
# Is the compiler the GNU compiler?
with_gcc=yes
--- 260,272 ----
# The linker used to build libraries.
! LD="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/ld"
# Commands used to build an old-style archive.
oldarchivecmds="$AR $AR_FLAGS $oldlib$oldobjs~$RANLIB $oldlib"
# A language specific compiler.
! CC="/Developer/Platforms/iPhoneOS.platform/Developer/usr/bin/gcc"
# Is the compiler the GNU compiler?
with_gcc=yes
It seems to work:
file ./.libs/libpng12.0.dylib
./.libs/libpng12.0.dylib: Mach-O dynamically linked shared library arm
You don't need to create static libraries. Just use the "install
nametool" to change the location of the dynamic libraries to @executable_path and include the required libraries inside your application bundle.