Using SQLite3 from C++ application

Discussion in 'Mac Programming' started by Kurukuru, Apr 12, 2009.

  1. Kurukuru Guest

    Hi all,

    I'm an experienced C++ developer, but am relatively new to Mac development. I want to write an application that makes use of a simple database and SQLite3 would suit my needs.

    Mac OS X 10.5.6
    Xcode 3.1.2

    I've #included sqlite3.h, and pulled /usr/lib/sqlite3/libtclsqlite3.dylib into the project's Products section, and I get a runtime error when hitting the first SQLite3 call, sqlite3_open(...):
    dyld: Library not loaded: /usr/lib/sqlite/libtclsqlite3.0.dylib
    Reason: image not found

    Indeed, /usr/lib/sqlite/libtclsqlite3.0.dylib does not exist on my machine, and I don't know why it's being referenced. How do I control this? Why is /usr/lib/sqlite3/libtlcsqlite3.dylib not being loaded, as that's the library I've added to the project?

    Thanks for any help you can offer.
  2. garethlewis2 macrumors 6502

    Dec 6, 2006
    You don't need to link the dylib of Sqlite3 on OS X. sqlite3 is bundled as part of the OS as a prebound library and separate executable, all you need to do, is pass gcc the -lsqlite3 option to link it.
  3. Kurukuru thread starter Guest

    Thanks for the information. I'm still learning my way around Xcode...How do I provide gcc with the -lsqlite3 option, as I'm doing the build from the IDE, not the command line?

    Actually, I'd really like some documentation about this kind of thing, but haven't found anything specific to how Xcode builds the command lines for the tools; can you recommend anything?

Share This Page