A few months ago I found an Objective-C framework called SMySQL for connecting to MySQL databases via Objective-C. I wanted to test it out, so I tried writing a small test program that used it. That's when I found out that the SMySQL framework hadn't been updated since 2006, before Apple switched over to Intel processors. So I tried my hand at creating a universal binary version of the SMySQL framework.
The first thing I realized was that in order to make a universal binary framework that links to MySQL, I also need a universal binary of libmysqlclient (.a and .dylib). Unfortunately at this time, MySQL is not distributing universal binary versions of mysql. They only have versions for the individual processor types ppc, ppc64, x86, and x86_64.
So we start by downloading the source for MySQL
here. Unarchive that and cd into the mysql source folder. Now set the following environment variables:
export MACOSX_DEPLOYMENT_TARGET=10.5
export LDFLAGS="-lz"
export CC=gcc
export CFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -fno-omit-frame-pointer -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk"
export CPPFLAGS=""
export CXX=gcc
export CXXFLAGS="-arch ppc -arch ppc64 -arch i386 -arch x86_64 -g -Os -fno-omit-frame-pointer -fno-exceptions -fno-rtti -Wl,-syslibroot,/Developer/SDKs/MacOSX10.5.sdk"
These let the ./configure script know that we want to build a universal binary for OS X 10.5. Next, you need to run the ./configure script with whatever options you want included or disabled in your copy of MySQL. The only option you
must use as a configure option is
--disable-dependency-tracking. GCC 4.0 will not build for multiple architectures when using dependency tracking. Here's the configure command line I used:
./configure --prefix=/opt/mysql --with-extra-charsets=complex --enable-local-infile --enable-largefile --with-innodb --with-big-tables --with-unix-socket-path=/private/tmp/mysql.sock --with-comment --with-gnu-ld --disable-dependency-tracking --with-federated-storage-engine --with-csv-storage-engine --with-archive-storage-engine --with-blackhole-storage-engine --enable-assembler --enable-static --enable-shared
Once that finishes, run make, and a little while later, you have yourself a universal binary version of MySQL and its libraries.
The SMySQL Framework can be found at
code.google.com. It was originally written by Serge Cohen and his original project is hosted at
sourceforge.net. I attempted to contact Serge via the sourceforge project page to give him a copy of the updated Xcode project but never heard back from him.