PDA

View Full Version : Using SQLite3 from C++ application




Kurukuru
Apr 12, 2009, 06:25 AM
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.



garethlewis2
Apr 12, 2009, 08:00 AM
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.

Kurukuru
Apr 13, 2009, 04:07 AM
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?