Cocoa and SQL

Discussion in 'Mac Programming' started by MacDonaldsd, Jun 14, 2007.

  1. MacDonaldsd macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #1
    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.
     
  2. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #2
    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.
     
  3. garethlewis2 macrumors 6502

    Joined:
    Dec 6, 2006
    #3
    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.
     
  4. MacDonaldsd thread starter macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
  5. Eraserhead macrumors G4

    Eraserhead

    Joined:
    Nov 3, 2005
    Location:
    UK
    #5
  6. MacDonaldsd thread starter macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #6
    I can't get it to link to the mysql header file :(

    That site you posted looks to have the things I want though.
     
  7. garethlewis2 macrumors 6502

    Joined:
    Dec 6, 2006
    #7
    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?
     
  8. MacDonaldsd thread starter macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #8
    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.
     
  9. garethlewis2 macrumors 6502

    Joined:
    Dec 6, 2006
    #9
    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.
     
  10. MacDonaldsd thread starter macrumors 65816

    MacDonaldsd

    Joined:
    Sep 8, 2005
    Location:
    London , UK
    #10
    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.
     
  11. garethlewis2 macrumors 6502

    Joined:
    Dec 6, 2006
    #11
    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.
     

Share This Page