Flangy > Software Development > Mac OS X > LinkMySql

Keywords: Mac OS X, MySQL client, linking

LinkMySql

Summary

Shows how to statically link the MySQL client into an Objective-C project.

Downloads

Description

Under linker settings there's "-lz -lmysqlclient" to get zlib and the MySql client library.

Under search paths I've added the path to the MySQL libs. You may need to change this path if you've installed them into some other place. My MySQL headers are symlinked from /usr/include/mysql/. You may need to add a search path for them too.

You may need to edit the host, user, and password used to connect to MySQL. The default is to try the unnamed user on localhost with no password.

I don't use all that much Objective-C, as I'm using the C MySQL API. Exception handling is used to simplify quitting on a query error, though all the queries in this sample "should" work.

- Adam Vandenberg