Using the
MCPKit is one way to use MySQL from your Cocoa Application, and I decided to do just that. But there is that one problem since the project seems not to be all that alive - the compiled version is PPC only, no Universal Binary. Well, I thought, download the source and build the Framework on your own. I finally succeeded, but not without running into some troubles first.
This is a quick rundown on what to do to
compile the MCPKit_bundled as a Universal Binary and make it
independent from an installed mysqld on the Mac your App should run on. I merely concat the ideas gathered at different locations here, props where props are due, and this is at the following URLs:
myztik.katan.com/?p=197
www.osxentwicklerforum.de/thread.php?threadid=5110
I seem to be missing something since this makes the MCPKit run flawlessly, but only as long MySQL is locally installed...
Compile MCPKit_bundled
- Download the source MCPKit_src from here (I used Version 3.0.1 as of this writing)
- Delete (or move) the contents of MCPKit_src/mysql-local/lib; we will place our own UB Libraries there in a minute
- Create the missing files MCPKit/MCPKit_bundled-Info.plist and MCPKit/MCPKit_prefix.pch, easiest is by copying it from another project and ajdusting MCPKit_bundled-Info.plist
- Download MySQL Sources from here (I picked the GNU TAR archive for MySQL 5.0.51b)
- From within Terminal, navigate into the mysql-folder and configure the source with the following environment variables and flags:
MACOSX_DEPLOYMENT_TARGET=10.5 \
CFLAGS='-O3 -fno-omit-frame-pointer -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
LDFLAGS='-arch i386 -arch x86_64 -arch ppc7400 -arch ppc64' \
CXXFLAGS='-O3 -arch i386 -arch x86_64 -arch ppc7400 -arch ppc64 -fno-omit-frame-pointer -fno-rtti' \
./configure \
--prefix=/usr/local/mysql \
--disable-dependency-tracking \
--enable-thread-safe-client \
--enable-local-infile \
--with-mysqld-user=_mysql \
--with-zlib-dir=/usr \
--with-archive-storage-engine \
--with-csv-storage-engine \
--with-federated-storage-engine \
--enable-dtrace \
--with-openssl
(Props to cmittendorf for this one)
- make your own MySQL (will take a while)
- Find the libraries libmysqlclient.dylib and libmysqlclient.a in mysql-5.0.51b/libmysql/.libs. Copy these into the lib-folder we previously emptied: MCPKit_src/mysql-local/lib
- Now we're ready to launch Xcode, so open MCPKit.xcodeproj
- Click on "Targets" » "MPCKit_bundled" and open the Info Panel
- Make sure ppc as well as i386 are active
- Click Build. It should compile, although with a respectable amount of warnings
After that, build the target
MCPKit_bundled in a
Release configuration and add it as a framework to your project as described
in the documentation of MCPKit (PDF) (Mirrored
here).
Rafael: Thank you very much, I was having a huge headache to solve the very same problem!