Categories:
| May 2012 | ||||||
|---|---|---|---|---|---|---|
| S | M | T | W | T | F | S |
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | 31 | ||
Monthly Archives:
Most recent entries:
Syndicate:
XCode C MySQL Connector
I found out adding the MySQL library to XCode was more work than I excepted. So here’s a short overview of everything you need to configure for XCode to build against MySQL.
- Download MySQL Connector for C
https://dev.mysql.com/downloads/connector/c/ - Start a new project in XCode (DUH!)
- Add ‘lib/libmysqlclient.dylib’ to ‘Link Binary With Libraries’
‘Link Binary With Libraries’ can be found in Targets, executable.
If you’ve done this right you see the libmysqlclient.dylib in the overview twice, like on the picture above.
- Install the resources on the filesystem
Note. This is not really required, you can add the headers to your download-folder, I found it clean to move them to /usr/local
To quote StackOverflow (man I love that forum):
The lib/ files go in /usr/local/lib The include/ files go in /usr/local/include The bin/ files go in /usr/local/bin Add the headers to XCode
Next is adding the headers to XCode so it can find them. Open the ‘project settings’ by right-clicking on your base-project file and select ‘Get Info’.
Add Header Search Paths
Last step, go to ‘Build’, scroll down to the group ‘Search Paths’ and add ‘/usr/local/include’ to the ‘Header Search Paths’.
Can’t connect to local MySQL server through socket ‘/tmp/mysql.sock’ error
If you get this error message while running your code. The easiest solution to solve this is by changing ‘localhost’ to ‘127.0.0.1’ in your connecting code.
Sources:
http://zetcode.com/tutorials/mysqlcapitutorial/
http://stackoverflow.com/questions/1992592/c-api-with-mysql-in-xcode
http://stackoverflow.com/questions/4615442/how-to-install-mysql-connector-c-on-mac-os-x
http://stackoverflow.com/questions/749027/how-to-add-a-global-include-path-for-xcode
http://stackoverflow.com/questions/1297005/xcode-include-paths
http://drupal.org/node/184465
Comments
Geplaatst door studio33 op 06-Jul-11 02:07
I am getting error code tmp/mysql.sock when I try to connect to the local MySQL server.
Can you shed any light on that?