Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/sqlite/blob/master/doc/compile-for-windows.md # sqlite [Ported from github.com/sqlite/sqlite] Fix bugs in and improve the interface to the ".check" command of the CLI. Brought by drakestapleton Sign in to star 0 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `master` Branches Tags History `sqlite / doc / compile-for-windows.md` 186 lines ยท 8474 bytes Raw Blame History Rendered 1 # Notes On Compiling SQLite On Windows 11 2 3 ## Executive Summary 4 5 1. Install Microsoft Visual Studio 6 2. Get a "Native Tools Command Prompt" 7 3. Get a tarball of the canonical SQLite source tree and unpack it 8 4. Run commands like: 12 13 ## Details For Standard 64-bit Builds On Either x64 Or ARM 14 15 Below are step-by-step instructions on how to build SQLite from 16 canonical source on a new Windows 11 PC, as of 2026-08-01. 17 See [](./compile-for-unix.md) for a similar guide for unix-like 18 systems, including MacOS. 19 20 1. Install Microsoft Visual Studio. The free "community edition" 21 will work fine. Do a standard install for C++ development. 22 SQLite only needs the 23 "cl" compiler and the "nmake" build tool. 24 33 34 2. Under the "Start" menu, find "All Apps" then go to "Visual Studio 20XX" 35 and find "x64 Native Tools Command Prompt for VS 20XX". Pin that 36 application to your task bar, as you will use it a lot. Bring up 37 an instance of this command prompt and do all of the subsequent steps 38 in that "x64 Native Tools" command prompt. (Or use "x86" if you want 39 a 32-bit build. Or use "ARM64" if you want to do a build for Windows 40 on ARM.) The subsequent steps will not work in a vanilla 41 DOS prompt. Nor will they work in PowerShell. 42 43 3. *(Optional):* Install TCL development libraries. 44 This note assumes that you will 45 install the TCL development libraries in the "`c:\Tcl`" directory. 46 Make adjustments 47 if you want TCL installed somewhere else. SQLite needs both the 48 "tclsh90.exe" command-line tool as part of the build process, and 49 the "tcl90.lib" and "tclstub.lib" libraries in order to run tests. 50 This document assumes you are working with TCL version 9.0. 51 See [](./tcl-extension-testing.md#windows) for guidance on how 52 to compile TCL version 8.6 for use with SQLite. 53
    54
  1. Get the TCL source archive, perhaps from 55 56 or . 57
  2. Untar or unzip the source archive. CD into the "win/" subfolder 58 of the source tree. 59
  3. Run: `nmake /f makefile.vc INSTALLDIR=c:\Tcl release` 60
  4. Run: `nmake /f makefile.vc INSTALLDIR=c:\Tcl install`
    61 Notes: 62
      63
    1. The previous two `nmake` commands must be run separately. 64
    2. Also, the INSTALLDIR=... argument is required on both. 65
    66
  5. Optional: CD to `c:\Tcl\bin` and make a copy of 67 `tclsh90.exe` over into just `tclsh.exe`. 68
  6. Optional: 69 Add `c:\Tcl\bin` to your %PATH%. To do this, go to Settings 70 and search for "path". Select "edit environment variables for 71 your account" and modify your default PATH accordingly. 72 You will need to close and reopen your command prompts after 73 making this change. 74
75 76 As of 2024-10-25, TCL is not longer required for many 77 common build targets, such as "sqlite3.c" or the "sqlite3.exe" 78 command-line tool. So you can skip this step if that is all 79 you want to build. TCL is still required to run "make test" 80 and similar, or to build the TCL extension, of course. 81 82 4. Download the SQLite source tree and unpack it. CD into the 83 toplevel directory of the source tree. 84 85 5. The source tree contains the "`make.bat`" batch script that 86 simulations the behavior of Unix-style "make" using "`nmake`". 87 So the build process for Windows is the same as for Unix: 88 94

No TCL is required for the make targets above. But for the ones 95 that follow, you will need a TCL installation, as described in step 3 96 above. If you install TCL in some directory other than C:\\Tcl, then 97 you will also need to add the "TCLDIR=<dir>" option on the 98 nmake command line to tell nmake where your TCL is installed. 99

104 105 It is not required that you run the "tclextension-install" target prior to 106 running tests. However, the tests will run more smoothly if you do. 107 The version of SQLite used for the TCL extension does *not* need to 108 correspond to the version of SQLite under test. So you can install the 109 SQLite TCL extension once, and then use it to test many different versions 110 of SQLite. 111 112 113 7. For a debugging build of the CLI, where the ".treetrace" and ".wheretrace" 114 commands work, add the DEBUG=3 argument to nmake. Like this: 115 118 119 ## 32-bit Builds 120 121 Doing a 32-bit build is just like doing a 64-bit build with the 122 following minor changes: 123 124 1. Use the "x86 Native Tools Command Prompt" instead of 125 "x64 Native Tools Command Prompt". "**x86**" instead of "**x64**". 126 127 2. Use a different installation directory for TCL. 128 The recommended directory is `c:\tcl32`. Thus you end up 129 with two TCL builds: 130 134 135 3. Ensure that `c:\tcl32\bin` comes before `c:\tcl\bin` on 136 your PATH environment variable. You can achieve this using 137 a command like: 138 141 142 ## Building a DLL 143 144 The command the developers use for building the deliverable DLL on the 145 [download page](https://sqlite.org/download.html) is as follows: 146 147 > nmake /f Makefile.msc sqlite3.dll USE_NATIVE_LIBPATHS=1 "OPTS=-DSQLITE_ENABLE_FTS3=1 -DSQLITE_ENABLE_FTS4=1 -DSQLITE_ENABLE_FTS5=1 -DSQLITE_ENABLE_RTREE=1 -DSQLITE_ENABLE_JSON1=1 -DSQLITE_ENABLE_GEOPOLY=1 -DSQLITE_ENABLE_SESSION=1 -DSQLITE_ENABLE_PREUPDATE_HOOK=1 -DSQLITE_ENABLE_SERIALIZE=1 -DSQLITE_ENABLE_MATH_FUNCTIONS=1" 148 149 That command generates both the sqlite3.dll and sqlite3.def files. The same 150 command works for both 32-bit and 64-bit builds. 151 152 ## Linking Against ZLIB 153 154 Some feature (such as zip-file support in the CLI) require the ZLIB 155 compression library. That library is more or less universally available 156 on unix platforms, but is seldom provided on Windows. You will probably 157 need to provide it yourself. Here the the steps needed: 158 159 1. Download the zlib-1.3.1.tar.gz tarball (or a similar version). 160 Unpack the tarball sources. You can put them wherever you like. 161 For the purposes of this document, let's assume you put the source 162 tree in c:\\zlib-64. Note: If you are building for both x64 and 163 x86, you will need separate builds of ZLIB for each, thus separate 164 build directories. 165 166 2. Before building SQLite (as described above) first make these 167 environment changes. The lead-programmer for SQLite (who writes 168 these words) has BAT files named "env-x64.bat" and "env-x32.bat" 169 and "env-arm64.bat" that make these changes, and he runs those 170 BAT file whenever he starts a new shell. These are the settings 171 needed: 172
173 set USE_ZLIB=1
174 set BUILD_ZLIB=0
175 set ZLIBDIR=c:\\zlib-64 176
177 178 3. Because the settings in step 2 specify "BUILD_ZLIB=0", you will need 179 to build the library at least once. I recommand: 180
181 make clean sqlite3.exe BUILD_ZLIB=1 182
183 184 4. After making the environment changes specified in steps 1 through 3 185 above, you then build and test SQLite as you normally would. The 186 environment variable changes will cause ZLIB to be linked automatically.