How do I include a SQLite DLL in my C++ project? How do I include a SQLite DLL in my C++ project? sqlite sqlite

How do I include a SQLite DLL in my C++ project?


Here's what worked for me:

In Visual Studio 2010, click on "Tools, VS Command Prompt"

In the command line window, enter, for example:

lib /DEF:"C:\SQLite\sqlite3.def" /OUT:"C:\SQLite\sqlite3.lib"

In the Solution Explorer window, right-click on your project, add the "sqlite3.lib" file.

(You'd think the SQLite gang could include a .lib in the download?)


If I remember right sqlite is written in C.Does the sqlite3.h file have

extern "C" {}

wrapping the declarations? You might be having name mangling issues.


Update: SQLite 3.28 doesn't seem to ship with a .DEF file. To create the DEF and LIB, do:

:: Dump SQLite.DLL exportsset DUMPBIN="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x86\dumpbin.exe"set LIBX="C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\VC\Tools\MSVC\14.16.27023\bin\Hostx86\x86\lib.exe"set SQL="C:\SQLite\sqlite3.dll"set DEF="C:\SQLite\sqlite3.def"set LIB="C:\SQLite\sqlite3.lib":: [1] run dumpbin%DUMPBIN% /EXPORTS /NOLOGO /OUT:%DEF% %SQL%:: [2] manually edit .DEF file to look proper:: [3] run LIB%LIBX% /DEF:%DEF% /OUT:%LIB%