Setting Up SQLite3 on Linux

Hello

I have read almost whole internet about setting up SQLite3 but without effect! I am really frustrated at this point and I would really appreciate some assistance with it. I am not going to describe all errors and problems I went through, instead I would like you to take my step by step through this process. I would REALLY appreciate this!!!!!!!!
In details, I would like to use SQLite3 database in my C++ project. I would like to set it up for Code::Blocks AND Sublime Text(although setting this up for Sublime Text is not necessary). I use Linux Mint. THANK YOU FOR YOUR HELP!!!
Have a nice day !!!
I would presume that you start by installing package libsqlite3-dev
is it the same as just installing SQLite3? If so i have it already installed an i can use it from terminal?
if it is not the same how should i install it?
I do guess that the sqlite is first and foremost a library that is called and linked with other code, just like, say the iostream.

If you already have a compiled binary of a program, then you only need the library file(s). Dynamically linked, shared objects, ...
My guess is that Mint has that in package named libsqlite3.

For compiling a program you do need the header file(s) of the library. You need to include the necessary headers in your source code and you need to tell the linker to use the library. Mint seems to put the header file in package named libsqlite3-dev. If a library has name libfoo.so, then one would add option -lfoo for g++ (that passes it to linker).

There is probably a dependency that installing libsqlite3-dev will install the library package too.

I don't use Mint, but it probably has both CLI and GUI package management tools. If you don't know how to use them, then you really should learn.


The Code::Blocks and Sublime are some GUI gizmos? Do they have a concept of "project" and a button to "build"? There is probably some "additional libraries to link into project" option too?
Do I need to include anything in source code using #include directive? If so, what exactly?
Of course you have to. How else could you use the library?

Probably #include <sqlite3.h>

https://www.sqlite.org/cintro.html
https://www.sqlite.org/quickstart.html
when i try to include it by #include <sqlite3.h> and pass -lsqlite3 to g++ compiler it still gives me an error that sqlite3.h no such a file or directory. when i compile it in codeblcks it says that it cannot find -lsqlite3. This is when i try to complite c program from https://www.tutorialspoint.com/sqlite/sqlite_c_cpp.htm. the first one titled "connecting to database".
Just to clarify, I tried: g++ test.cpp -lsqlite3

#include <sqlite3.h> no such a file or directory
it seems that you haven't correctly installed the library.
¿what command did you use?

you should have
/usr/include/sqlite3.h
/usr/libsqlite3.so

(perhaps in /usr/local/)
Last edited on
Idea: Maybe compiler doesnt have path provided to sqlite3? Becuase I can use it perfectly fine from the terminal...

I have: libsqlite3.so in /opt/google/earth/free type: unknown
libsqlite3.so.0 in /usr/lib/i386-linux-gnu type: Link to unknown
libsqlite3.so.0.8.6 in /usr/lib/i386-linux-gnu type: unknown
I have sqlite3.h in home/filip/Downloads/sqlite-autoconf-3180000
the program and the library are two different things.
you haven't installed the library correctly.
You were right libsqlite3-dev wasnt installed. Now I've installed it and used this command: g++ SQLite3.c -l sqlite3
no errors, but compiler didnt create executable file...
i have insntlled like following: sudo apt-get update
sudo apt-get install libsqlite3-dev
when i compile it with Code::Blocks it points out over 50 errors in sqlite3.c concerning pthread and dl kind of things...
SOLVED! THANK YOU VERY MUCH FOR PATIENCE AND USEFUL FEEDBACK!
Topic archived. No new replies allowed.