Error: undefined reference to `sqlite3_open'

You need to adjust your linker flags to link in the sqlite3 library. Libraries are usually installed in /usr/lib or /usr/lib64

Alternatively, you can copy the sqlite3.c file to your project directory and compile it as part of the g++ command:

g++ main.cpp sqlite3.c 

as per: http://sqlite.org/cvstrac/wiki?p=HowToCompile


You need to link the sqlite3 library along with your program:

g++ main.cpp -lsqlite3

First step: Install all library sqlite3 with the command:

        sudo apt-get install libsqlite3-dev

With that you can use #include <sqlite3.h> in a programm of C or C++.

Second step: To compile the program by console:

C++:

        g++ program.cpp -o executable -lsqlite3

        ./executable

C:

        gcc program.c -o executable -lsqlite3

        ./executable

Tags:

C++

Sqlite