I'm trying to use functions defined in a third-party dynamic library (libmysql) in a desktop app for Mac OS X. I'm using XCode 4.5.1 on Mac OS X v. 10.8.2.
Here's what I've done so far:
1) I downloaded the Mac OS X 10.5 x86 64-bit C connector files from http://dev.mysql.com/downloads/connector/c/ (this is the most recent version available).
2) I copied the files from the disk image to a local directory.
3) I added the path to that local directory to my project's Build Settings->Search Paths->User Header Search Paths and set "Always Search User Paths" to "Yes"
4) I added libmysql.client to Build Phases->Copy Files
5) I added libmysql.client to Copy Bundle Resources
6) I wrote a test function in my code:
#import "mysql.h"
-(NSNumber*)testFunction {
mysql_library_init(0, NULL, NULL);
mysql_library_end();
return [NSNumber numberWithInt:8];
}
The project compiles (target:My Mac 64-bit), but I get "Undefined symbols for architecture x86_64" errors for the two mysql functions from the linker. Here is the full error message:
Ld "/Users/chapka/Library/Developer/Xcode/DerivedData/The_Single_Table_Admin_Tools-ctdgurwiktybjqcnlfuufetgimfy/Build/Products/Debug/The Single Table Admin Tools.app/Contents/MacOS/The Single Table Admin Tools" normal x86_64 cd "/Users/chapka/Documents/Developer/The Single Table/The Single Table Admin Tools" setenv MACOSX_DEPLOYMENT_TARGET 10.8 /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/clang -arch x86_64 -isysroot /Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.8.sdk -L/Users/chapka/Library/Developer/Xcode/DerivedData/The_Single_Table_Admin_Tools-ctdgurwiktybjqcnlfuufetgimfy/Build/Products/Debug "-L/Users/chapka/Documents/Developer/The Single Table/The Single Table Admin Tools" "-L/Users/chapka/Documents/Developer/The Single Table/The Single Table Admin Tools/The Single Table Admin Tools" "-L/Users/chapka/Documents/Developer/The Single Table/The Single Table Admin Tools/../../Libraries/mysql" -F/Users/chapka/Library/Developer/Xcode/DerivedData/The_Single_Table_Admin_Tools-ctdgurwiktybjqcnlfuufetgimfy/Build/Products/Debug -filelist "/Users/chapka/Library/Developer/Xcode/DerivedData/The_Single_Table_Admin_Tools-ctdgurwiktybjqcnlfuufetgimfy/Build/Intermediates/The Single Table Admin Tools.build/Debug/The Single Table Admin Tools.build/Objects-normal/x86_64/The Single Table Admin Tools.LinkFileList" -mmacosx-version-min=10.8 -fobjc-arc -fobjc-link-runtime -framework Cocoa -o "/Users/chapka/Library/Developer/Xcode/DerivedData/The_Single_Table_Admin_Tools-ctdgurwiktybjqcnlfuufetgimfy/Build/Products/Debug/The Single Table Admin Tools.app/Contents/MacOS/The Single Table Admin Tools"
Undefined symbols for architecture x86_64: "_mysql_server_end", referenced from: -[TSTDataSource gameCount] in TSTDataSource.o "_mysql_server_init", referenced from: -[TSTDataSource gameCount] in TSTDataSource.o ld: symbol(s) not found for architecture x86_64 clang: error: linker command failed with exit code 1 (use -v to see invocation)
I've looked around for other questions like this, but they all seem to be solved by steps 4 and/or 5 above. The only other suggestion I found was to use install_name_tool, but I'm not sure what exactly I would need to change or what I would need to change it to. If this is the likely issue, any hints would be more than welcome.