views:

408

answers:

3

Anyone manage to write code that uses the mysqlclient library? I can get compiling working but not linking :(

XCode produces the following output:

Build TestMysql of project TestMysql with configuration Debug

Ld build/Debug/TestMysql normal x86_64
cd /Users/jacob/Documents/cocoa/TestMysql
setenv MACOSX_DEPLOYMENT_TARGET 10.5
/Developer/usr/bin/gcc-4.2 -arch x86_64 -isysroot /Developer/SDKs/MacOSX10.5.sdk
   -L/Users/jacob/Documents/cocoa/TestMysql/build/Debug -L/usr/local/mysql/lib
   -L/usr/local/mysql-5.1.38-osx10.5-x86_64/lib
   -F/Users/jacob/Documents/cocoa/TestMysql/build/Debug -filelist /Users/jacob/Documents/cocoa/TestMysql/build/TestMysql.build/Debug/TestMysql.build/Objects-normal/x86_64/TestMysql.LinkFileList
   -mmacosx-version-min=10.5 -lm -lz -lmysqlclient -lmygcc "
" -framework CoreFoundation -o /Users/jacob/Documents/cocoa/TestMysql/build/Debug/TestMysql

i686-apple-darwin10-gcc-4.2.1: 
: No such file or directory
Command /Developer/usr/bin/gcc-4.2 failed with exit code 1

And yes I already know about the mysql/cocoa framework, im writing code that must compile on os/x and linux. Ironically it only took me 20 minutes to work out how to write a make file to compile and link and run objective-c / mysql code, but xcode is soo much more complicated.

+1  A: 

I believe the "" string is causing you grief -- especially since the error message's filename is the empty string.

Alternate methodology: Have you considered just using the Makefile you made in XCode?

File->New Project->Other->External Build System.

Apple docs on this method: http://bit.ly/dYNuR

nall
Good suggestion, I did not know you could do that. However I would prefer to take advantage of the apple tools primarily develop in xcode on my mac, and then just use makefiles to build linux versions.
Jacob
A: 

Ok, its an xcode bug. Under the screen to add linker options with the + and - buttons, somehow there was an extra link option with a CR or LF in it. Don't ask me how it got there I don't know! (:

That comment about the weird "" helped me solve it (eventually).

Jacob
sorry for the offtopic, but what is your icon? i've seen a lot of them on OS.
nall
A: 

I know this is an old post but for anyone that has the same issue...

Make sure you install into the /usr/local by first setting the make files: sudo cmake -G "Unix Makefiles" -DCMAKE_INSTALL_PREFIX=/usr/local

Then, 'make install' will put everything in the right directories. Next, in Xcode, you have to right click a folder in the project, say add existing framework, change the drop down to pick dylibs, finally choose libmysql.dylib.

The libmysql.dylib is a shared library that xcode needs to look at for the function names.

joels