I’m a complete beginner with Code::Blocks and SQLite, and have some basic knowledge with C++. I’m currently using Ubuntu 11.04.
I have downloaded SQLite Amalgamation here. When I extracted the zip file, there are four files inside: shell.c, sqlite3.c, sqlite3.h, and sqlite3ext.h. If I simply add those files to a (for example) a console project, it gives out an error: the .c’s of the downloaded sqlite each have their own main function. Removing those from the project, the errors are gone and I can call #include "sqlite3.h". I am trying to follow this, and tried the first two lines of code from here and it gives out an error: undefined reference to sqlite3_open.
I think adding those .h’s directly to a console project isn’t the right way to use it, though I’m not sure.
How exactly should I use those? What should I do to use those for my C++ program?
Any help is greatly appreciated. 🙂
EDIT: I also tried to create a .a file of those sqlite files by following this. When I try it, it gives out an error: cannot find -lsqlite.
You will need to compile the sqlite code first, and then just
#include "sqlite3.h"into your project where you need it.UPD:
Try this:
Download this package from sqlite site and extract it somewhere, say, into a folder called “sqlite”. Open terminal, and go into this folder. Inside of it, run
and see what happens. It should build itself automatically. Consult the README file that is inside the archive too.