Compile SQLite3 with Visual Studio on Windows
· One min read
The simplest Windows build uses the SQLite amalgamation files sqlite3.c and sqlite3.h downloaded from the official source package.
Create a Visual Studio C or C++ project, add sqlite3.c to the compiled sources, and make the directory containing sqlite3.h available through the include path. Ensure the runtime-library, architecture, and debug/release settings match the application that will link the result.
A minimal verification program:
#include <stdio.h>
#include "sqlite3.h"
int main(void) {
sqlite3 *db = NULL;
int rc = sqlite3_open("test.db", &db);
if (rc != SQLITE_OK) {
fprintf(stderr, "%s\n", sqlite3_errmsg(db));
sqlite3_close(db);
return 1;
}
sqlite3_close(db);
return 0;
}
Compile-time options can enable or omit SQLite features, so record them for reproducibility. Do not mix x86 and x64 objects or incompatible C runtime settings. Verify the library with a small create/insert/query test and preserve the SQLite license notice in redistributed packages.