C API with Mysql in XCode
Setup: Running Mac OSX Snow Leopard, X Code 3.2.1, Mysql 5.1.42 and Mysql C-Connector 6.0.2, all 64-bit.
I am having real difficulty configuring X-Code to run Mysql scripts. XCode is running fine (i.e. can Build and Run), MySQL server is running and I am confident on the installation of the programs listed under my Setup at the top of this post. The problem is when I Build & Run I get 2 different errors over the hours of trying: either mysql.h cannot be found (so all Mysql script commands fail) or I get a "dyld: Library not loaded: libmysql.16.dylib" when I configure it with the correct include file location. I ran mysql_config and the results were:
--include: -I/usr/local/include
--libs: -L/usr/local/lib -lmysql -lpthread
--cflags: -I/usr/local/include
--libs_r: -L/usr/local/lib -lmysql -lpthread
It seems to me that I am not开发者_JS百科 configuring the Project Settings correctly in X Code, namely: Search Paths - Header Search Paths Search Paths - Library Search Paths Linking - Other Linker Flags
I also followed advice on the following forum: http://forums.mysql.com/read.php?117,51324,127220#msg-127220
Amongst many other things.
I would really value any advice - all coding has ceased until this error can be resolved!
Thank you in advance.
Oliver
Finally got the fix. This happens because the dylib files are not installed properly. In order to make the dylib files the proper way, do (supposing that we have our libraries on usr/local/mysql/lib
):
sudo install_name_tool -id /usr/local/mysql/lib/NAMEOFTHELIB.dylib NAMEOFTHELIB.16.dylib
This will add in the absolute path, and will make the libraries work.
精彩评论