Problems linking to sqlite3.h with gcc Problems linking to sqlite3.h with gcc sqlite sqlite

Problems linking to sqlite3.h with gcc


SQLite is a source only library. You embed the source into the application, not linking with it. So the undefined reference comes from the fact that you fail to include the source file of sqlite. Try compiling as

gcc -O3 sqliteTest.c sqlite3.c -o sqliteTest -lpthread -ldl


This works

gcc ./sqliteTest.c -o sqliteTest -lsqlite3


Well, first you should #include <stdlib.h> to have an appropriate declaration of exit() in scope, and second you should remember that what you're trying to link with is named "sqlite3", and replace the -lsqlite in your link line with -lsqlite3.