Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

MacDonaldsd

macrumors 65816
Original poster
Sep 8, 2005
1,005
0
London , UK
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

macrumors G4
Nov 3, 2005
10,434
12,250
UK
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

macrumors 6502
Dec 6, 2006
277
1
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.
 

garethlewis2

macrumors 6502
Dec 6, 2006
277
1
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

macrumors 65816
Original poster
Sep 8, 2005
1,005
0
London , UK
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

macrumors 6502
Dec 6, 2006
277
1
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

macrumors 65816
Original poster
Sep 8, 2005
1,005
0
London , UK
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

macrumors 6502
Dec 6, 2006
277
1
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.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.