SQLite 64-bit Binaries for Windows and How to Build Them with Visual Studio 2015

For the impatient ones: everything is available for download here (version 3.8.11.1). Both sources and binaries are included, so you can re-build everything yourself. If you are interested only in the development files (includes, binaries and libs for linking), they are here.

Now a little bit more details. First of all, why this blog post? Because as of today, there are no official x64 binaries available on the official SQLite download page. If you want to build the library yourself, you have two options. Either the full sources, or the amalgamated version (details about what that means are here). For building the full sources, you need some additional dependencies. As for the amalgamated version – there are some one line style build instructions for Microsoft tooling here, but to be honest, the result is unusable (the library will not contain the export symbols).

So how to compile the library ourselves?

  1. You will need the amalgamated version of the sources, the one I am working with is version 3.8.11.1, available here. Download and unpack it somewhere.
  2. Open your visual studio (I am using Microsoft Visual Studio Community 2015) and create a blank solution (menu File -> New -> Project -> choose Other Project Types -> Visual Studio Solutions -> Blank Solution), call it for example sqlite3_build.
  3. Create the project for the library (menu File -> Add -> New Project -> Visual C++ -> Win32 -> Win32 Project), call it for example sqlite3_dll. In Application Settings, choose DLL, untick Precompiled header and Security Development Lifecycle checks, tick Empty project.
  4. Copy the sqlite3.h and sqlite3.c file from the extracted amalgamated SQLite sources to the sqlite3_dll project directory and add them to the project (Solution Explorer -> right click the sqlite3_dll project -> Add -> Existing Item -> choose both the files).
  5. Choose the build configuration you want (Debug / Release, x86 / x64) and in project properties, add the following defines (Solution Explorer -> right click the sqlite3_dll project -> Properties -> Configuration Properties -> C/C++ -> Preprocessor -> Preprocessor Definitions -> add to the existing ones):
    SQLITE_ENABLE_FTS4=1
    SQLITE_ENABLE_RTREE=1
    SQLITE_ENABLE_COLUMN_METADATA=1
    SQLITE_API=__declspec(dllexport)
    I digged these values partly from the Visual Studio make file from the main source archive and partly they are just my effort. You can define more if you need to, details are here.
  6. In the project properties, choose the suitable output name (Solution Explorer -> right click the sqlite3_dll project -> Properties -> Configuration Properties -> General -> Target Name), for example sqlite3.
  7. Build the library (menu Build -> Build Solution).
  8. Create the project for the shell (menu File -> Add -> New Project -> Visual C++ -> Win32 -> Win32 Console Application), call it for example sqlite3_shell. In Application Settings, choose Console application, untick Precompiled header and Security Development Lifecycle checks, tick Empty project.
  9. Set a proper dependency of the sqlite3_shell project on the sqlite3_dll project (Solution Explorer -> right click the sqlite3_shell project -> Build Dependencies -> Project Dependencies -> tick sqlite3_dll).
  10. Copy the shell.c file from the extracted amalgamated SQLite sources to the sqlite3_shell project directory and add it to the project (Solution Explorer -> right click the sqlite3_shell project -> Add -> Existing Item -> choose shell.c).
  11. In the sqlite3_shell project properties, choose the suitable output name (Solution Explorer -> right click the sqlite3_shell project -> Properties -> Configuration Properties -> General -> Target Name), for example sqlite3.
  12. In the sqlite3_shell project properties, add the include directory for the library h file (Solution Explorer -> right click the sqlite3_shell project -> Properties -> Configuration Properties -> VC++ Directories -> Include Directories -> Add $(SolutionDir)\sqlite3_dll).
  13. In the sqlite3_shell project properties, add the library created in the step 7 as the input for the linker (Solution Explorer -> right click the sqlite3_shell project -> Properties -> Configuration Properties -> Linker -> Input -> Additional Dependencies -> Add $(SolutionDir)\$(PlatformTarget)\$(Configuration)\sqlite3.lib).
  14. Build the executable (menu Build -> Build Solution).

Hope this short tutorial will help you to build your own SQLite binaries. It is applicable to x86 as well (with the slight difference in step 13 – you have to leave out the $PlatformTarget part), the files for download include all 4 configuration combinations.

Feel free to mail me your opinions or remarks.