Skip to content

Instantly share code, notes, and snippets.

@payalord
Last active June 7, 2024 06:56
Show Gist options
  • Save payalord/c87cbd1d12ea7712449657d1c6583e12 to your computer and use it in GitHub Desktop.
Save payalord/c87cbd1d12ea7712449657d1c6583e12 to your computer and use it in GitHub Desktop.
How to add SQLite into your VS project as Static Library

I assume that you already created C++ Win32 project where you want to include SQLite.

  1. Navigate to https://www.sqlite.org/download.html and download latest amalgamation source version of SQLite.
  2. Extract all the files into your project directory, or your include path, or separate path that you will add/added as include path in your project properties.
  3. Run Developer Command Prompt for VS **** which is usually available at Start -> Programs -> Visual Studio **** -> Visual Studio Tools.
  4. Navigate with command prompt to that directory where we extracted our SQLite.
  5. Run next command to compile: cl /c /EHsc sqlite3.c
  6. Run next command to create static library: lib sqlite3.obj
  7. Open properties of your project and add sqlite3.lib to Linker -> Input -> Additional Dependencies.

Now you ready to include and use sqlite3.h in your project.

@valinet
Copy link

valinet commented Apr 17, 2020

Yes. If I run lib /list sqlite3.lib on it, it shows sqlite3.dll multiple times, which do not seem like proper objects to me. I am using Visual Studio 2017 cl v19). For now, it was pretty easy and the solution seemed to be just to compile it directly into the target application, since you just need the headers and the sqlite3.c file to do so and cl happily accepts mixed code (C and C++) in a single target. This being said, I would still like more to have it as a standalone static library...

@warbler
Copy link

warbler commented Sep 30, 2020

If anybody gets unresolved reference linker errors when trying to use the sqlite library, make sure that the bitness of the developer command prompt matches your target platform. It ran in 32 bit mode by default for me which I didn't realize at the time.

Thanks for this guide, it works perfectly.

@CycloneRing
Copy link

Worked perfectly thank you!

@float512
Copy link

float512 commented Jun 7, 2024

How would i go about doing this working on a windows application on linux?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment