View Full Version : Cocoa and SQL
MacDonaldsd
Jun 14, 2007, 03:52 AM
Im going into the final year of my computer science degree and its time for me to start my final year project.
I was thinking of doing a "student application" in Cocoa where one of the feature is a timetable.
Is there a way to be able to get this information off a SQL database held online ?
I would create the SQL database myself, what im looking for is if the student enters a module code it will auto populate the rest of the details for that module.
Eraserhead
Jun 14, 2007, 03:55 AM
I'd have thought so, if you can do it in C you can do it in Cocoa.
Though I have no idea how you'd actually do it.
garethlewis2
Jun 14, 2007, 05:08 AM
You don't need a package that accesses a database online. What you simply need is the connection information for the SQL server, whether it is Sybase, Oracle, MySQL, etc.
Then you can simply wrap the C API in a Cocoa object, so you can dispense with the really low-level database calls. It isn't difficult to get a simple object that does this type of work, but since in the MySQL C API there are over 300 functions, you might have bitten off far more than you can chew.
MacDonaldsd
Jun 14, 2007, 08:27 AM
Is there any good recourses to start from ?
Eraserhead
Jun 14, 2007, 08:30 AM
Is there any good recourses to start from ?
http://dev.mysql.com/doc/refman/5.0/en/c.html
Found from a google for mysql +c
MacDonaldsd
Jun 14, 2007, 03:31 PM
I can't get it to link to the mysql header file :(
That site you posted looks to have the things I want though.
garethlewis2
Jun 15, 2007, 02:12 AM
You don't link in header files. They are already brought in at compile time, which is not link-loader time. Did you just create a program and download the headers and libraries?
MacDonaldsd
Jun 15, 2007, 03:43 AM
I have a test source C file that I got got from the net.
If I do a simple #include <mysql/mysql.h> (like most guides tell you to do) it doesn't link to the the header file and therefore the pre defined things don't get recognized.
garethlewis2
Jun 15, 2007, 05:35 AM
You can't link a header, it isn't compiled code, all the compiler does it simply replace #include <whatever> with the text in that header. If ld can't find it, you will more than likely be receiving message saying there is an unresolved linkage problem. This is occuring as ld can't find the lib file that the header is referenced in. If you are using MySQL, you simply can't write a program to read from MySQL as you have the client and server installed and not the developer libraries. They do have these on their site.
MacDonaldsd
Jun 15, 2007, 06:40 AM
It says that the C API is included with mySQL
"The C API code is distributed with MySQL. It is included in the mysqlclient library and allows C programs to access a database."
But I don't seem to have these libraries when I install it.
garethlewis2
Jun 15, 2007, 08:51 AM
I have just looked at the MySQL website, so I see that the libs and headers should have been installed.
They should be in your OS X installation in /usr/local/mysql/lib. Since more than likely the installer for MySQL doesn't update the dylib locations you need to tell the gcc compiler where this library is. This is achieved by passing
-L/usr/local/mysql/lib -lmysqlclient -lz to gcc. You might want to check where MySQL has installed its libraries by running the find command.
vBulletin® v3.8.6, Copyright ©2000-2012, Jelsoft Enterprises Ltd.