Small. Fast. Reliable.
Choose any three.
Beginning with release 3.3.14, the core SQLite library is delivered as a single code file named "sqlite3.c", The programming interface is defined in a header file named "sqlite3.h". The header file comprises the first couple thousand lines of the amalgamated C code file so if you do not have a header file handy you can extract one from the C code.

To compile the core SQLite library into an object file or DLL or shared library, just hand the sqlite3.c code file to your C compiler. On Linux or Mac OS-X you just say:

    gcc -c sqlite3.c

The "sqlite3" command-line tool is really a separate program that uses the SQLite library to access an SQLite database. To compile the the command-line tool, get a copy of its source file (shell.c) and type:

    gcc shell.c sqlite3.c

You will probably need to add some system libraries like "-ldl" or "-lpthreads" to that last line in order to get it to work. You might also select various compile-time options by defining C preprocessor macros using the -D command-line switch to gcc. The available compile-time options are described separately.

The SQLite Build Process

The SqliteBuildProcess wiki page diagrams and describes the steps that the makefiles go through to transform source code into an SQLite library. You are not required to know this in order to compile SQLite, but some people find it useful background information.

Notes on compiling sqlite using eclipse and mingw

  1. Download eclipse 3.2.1
  2. Download eclipse CDT plugin for c/c++ (version 3.1.1)
  3. Download mingw (used MinGW-3.1.0-1.exe).
  4. Create a new project (managed make c++ project).
  5. Add all the .c files from sqlite source to the eclipse project created in the above step (you can copy all the .c files from explorer and paste into eclipse project).
  6. Build the project (right click on the project and build).
  7. Make sure you have make.exe available on windows.

If there are any errors in tclsqlite.c file delete this file from eclipse project.

Eclipse generates the makefiles required once you add the source files to the project.

* CodeWarrior: Notes on compiling on MacOS using CodeWarrior *

(see also the MacOSX command line instructions below)

If the "configure" script does not work for you, then you might have to compile manually. Fortunately, this is easy to do. First download the preprocessed source code from This archive contains a set of C source and header files that are ready to be passed to a C compiler. To build the library, just compile all of the files.

Note that the files "shell.c" and "tclsqlite.c" are special and do not belong in the SQLite library proper. "shell.c" is used to build the "sqlite" shell program and "tclsqlite.c" is the TCL bindings for SQLite. You may want to omit both of these files when you build the library.

For example, I was able to compile SQLite for HPUX as follows:

  rm tclsqlite.c
  for i in *.c; do c89 -O -c $i; done
  rm shell.o
  ar cr libsqlite.a *.o
  ranlib libsqlite.a
  c89 -o sqlite shell.c libsqlite.a

DJGPP (32 bit, protected memory DOS)

libsqlite.a and sqlite.exe may be made for djgpp in a similar way as with HPUX above. It compiles and works out of the box, with the following limitations:

1. Temporary files are not removed upon database close (journal file).

2. Files created by sqlite automatically will be correctly created only if lfn is enabled. Otherwise, lacking the journal file, the database will be open read-only.

My diffs are fixing both problems, and make sqlite work very well on djgpp.

To avoid overload of this page, I have attached patches to sqlite development tickets. Each patch applies for a certain sqlite version, as follows:

For sqlite 2.8.6: diff attached at

For sqlite 2.8.11: diff attached at

For sqlite 2.8.13: diff attached at

For sqlite 2.8.14: diff attached at

For sqlite 2.8.15: diff attached at

For sqlite 2.8.16: diff attached at

For sqlite 3.0.7: diff attached at

Please compile as follows:

  rm tclsqlite.c
  for i in *.c; do gcc -c $i; done
  rm shell.o
  ar crs libsqlit.a *.o
  RDLN_DEF=-DHAVE_READLINE=1 #if you wish to use
  gcc -DSQLITE_DISABLE_LFN $(RDLN_DEF) -c shell.c
  RDLN_LIBS=-lreadl -lhisto
  gcc -o sqlite.exe $(RDLN_LIBS) shell.o libsqlit.a

It will also do no harm to incorporate it in the main sqlite distribution.

I'm sorry it has not been evident until now, so i am explicitly including the following copyright disclaimer, as required by sqlite author:

The author or authors of this code dedicate any and all copyright interest in this code to the public domain. We make this dedication for the benefit of the public at large and to the detriment of our heirs and successors. We intend this dedication to be an overt act of relinquishment in perpetuity of all present and future rights this code under copyright law.

alex <>


Microsoft Visual Studio Illustrative Guide

The following site has an up-to-date illustrative guide on how to build the SQLite3 DLL on Microsoft Windows using Visual Studio 2005. It has the latest information on how to get and build the ICU Unicode Library that is now required to build SQLite3.

Those with earlier versions of Visual Studio should still be able to follow the steps and make small adjustments to get things to build.

The SQLite Guide can be found at:

Rajinder Yadav Nov 24, 2007

Microsoft Visual Studio 2005

I have a downloadable project and explanation here.

Microsoft Visual Studio.NET 2003

See VsNetSolution.

Microsoft Visual Studio.NET

See HowToCompileWithVsNet.

Visual C++ Toolkit 2003 combined with GNU Make/MSYS

For the there's a makefile which can be used with MSYS combined with Visual C++. This makefile can be found here


Creation of an import library from the ( for MS Visual C++ is achieved by the following command:

LIB /DEF:sqlite3.def

This makes the files sqlite3.lib and sqlite3.exp files. The sqlite3.lib can then be used to link your programs against the SQLite DLL.

Crosscompile linux x86 -> linux arm

With version 3.3.7 (don't know about other versions) I have figured out how to get configure to work without following the previous procedure defined below which required editing files.

The problem with the configure script is primarily that it doesn't give you a way to specify that you don't have readline for the target. This could easily be fixed if someone wants to tackle it by supporting a --without-readline option that skipped the readline checking and set TARGET_HAVE_READLINE to 0. The other problem is that you have to explicitly tell configure the compiler for both build and target.

Here is the command line I used to configure sqlite3.3.7 for cross compiling to arm-linux:

   ../configure --host=arm-linux config_BUILD_CC=gcc config_TARGET_CC=arm-linux-gcc --disable-
tcl config_TARGET_READLINE_INC=" "

Setting config_TARGET_READLINE_INC to something makes it skip looking for readline.h, which is what causes problems when cross compiling.

Previous procedure

1. Install skiff toolchain or similar, make sure you have arm-linux-gcc in your PATH.

2. Unpack sqlite sources and create a directory sqlite-arm in the same dir.

3. Edit configure script in the sqlite dir and comment following lines out as shown - have fun finding them ;-)

  if test "$cross_compiling" = "yes"; then
   { { echo "$as_me:12710: error: unable to find a compiler for building build tools" >&5
   echo "$as_me: error: unable to find a compiler for building build tools" >&2;}
   { (exit 1); exit 1; }; }

  . . .

    test "$cross_compiling" = yes &&
    { { echo "$as_me:13264: error: cannot check for file existence when cross compiling" >&5
    echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
    { (exit 1); exit 1; }; }

  . . .

   test "$cross_compiling" = yes &&
   { { echo "$as_me:13464: error: cannot check for file existence when cross compiling" >&5
  echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
   { (exit 1); exit 1; }; }

  . . .

   test "$cross_compiling" = yes &&
   { { echo "$as_me:13490: error: cannot check for file existence when cross compiling" >&5
  echo "$as_me: error: cannot check for file existence when cross compiling" >&2;}
   { (exit 1); exit 1; }; }

hint:in VI, find 'unable to find a compiler ' or 'cannot check for file existence '

4. Save the configure script, change into the build directory you created and call the edited configure script from the sqlite directory by using the following option:

../sqlite/configure --host=arm-linux

if you didn't want to use tcl like me, please add --disable-tcl in the command line

5. After that configure should have created a Makefile and a libtool script in your build directory. Open the Makefile using your favorite text editor and edit the following line:

BCC = arm-linux-gcc -g -O2

to see:

BCC = gcc -g -O2

in sqlite-3.3.6 version Makefile, if you want compile static library version of sqlite3(only one execute file for distribution) on ARM, edit Makefile ,


sqlite3$(TEXE): $(TOP)/src/shell.c .libs/ sqlite3.h

change to

sqlite3$(TEXE): $(TOP)/src/shell.c .libs/libsqlite3.a sqlite3.h


-o $@ $(TOP)/src/shell.c .libs/ \

change to

-o $@ $(TOP)/src/shell.c .libs/libsqlite3.a \

save and quit editor.

6. run make Now you should find "sqlite" in the current directory, and ".libs" directory in your build directory containing sqlite shared object files, like , static library file libsqlite.a.

Source (somewhat altered):

Win32 recompile with mingw32/msys

For a makefile which works with 3.0.7, see ticket #931. No need for MSYS.

	1. Download mingw from
	2. Get the sqlite3 source tree
	3. Get the makefile attached to #931
	4. Make sure you have 'gawk', 'sed' and 'grep' (call grep ggrep, or edit the makefile).  Also get upx
and install it.
	5. Type 'make'.
	6. Optionally type 'make doc'.  This requires you to have installed tcl, also available from

If you don't want to get and install upx, type 'make sqlite3.exe'.

When you are done, you will have a sqlite3.exe and a sqlite3.dll. The EXE requires the DLL.

see also how to BuildOnWindowsWithoutTcl
Older instructions for mingw, good as of sqlite source 2.8.13:

1. Download mingw from

2. Download msys from

3. Install mingw to c:\mingw and msys to c:\msys N.B.! Need to override msys installer's default to install in c:\mingw DO NOT co-mingle msys binaries with mingw's -- see:

4. Download the FULL sqlite source ( and extract it to desired location (e.g., c:\mysqlite). This will create, among other entries, a src subdirectory, (e.g., c:\mysqlite\src).

5. Create a sibling build directory (e.g., c:\mysqlite\build)

6. Start the msys.bat (in c:\msys), which opens msys shell window, and cd to sqlite build directory. Invoke (msys's) ../sqlite/configure. This generates a Makefile in the build directory.

7. Invoke mingw32-make to compile the resulting Makefile. (make isn't used anymore - see http://

8. Find within the source distribution a file called sqlite3.def. Copy it to the build directory.

9. Invoke: dllwrap --dllname sqlite.dll --def sqlite3.def *.o (or if this doesn't work, dllwrap --def sqlite3.def -v --export-all --driver-name gcc --dlltool-name dlltool --as as --target i386-mingw32 -dllname sqlite.dll -lmsvcrt *.o)

9. strip sqlite.dll

10. Ready.

Win32 recompile with borland c++ builder

1. Download preprocessed source from

2. Unzip the source to a project directory, e.g. C:\sqlite

3. Fire up your borland c++ builder and create a new dll project, plain C without mfc or something like that

4. Save the project as (e.g.) C:\sqlite\sqlite.bpr

5. Add the sqlite source files from c:\sqlite to the project

6. Remove the unit1.* files from your project

7. Even if .def files are not the clean way, it will be easier than rewriting the sourcecode. Create the file sqlite3.def with the following content and add it to the project:

   LIBRARY sqlite.dll
   sqlite_open    = _sqlite_open
   sqlite_close   = _sqlite_close
   sqlite_exec    = _sqlite_exec
   sqlite_last_insert_rowid   = _sqlite_last_insert_rowid
   sqlite_error_string   = _sqlite_error_string
   sqlite_interrupt   = _sqlite_interrupt
   sqlite_complete   = _sqlite_complete
   sqlite_busy_handler   = _sqlite_busy_handler
   sqlite_busy_timeout   = _sqlite_busy_timeout
   sqlite_get_table   = _sqlite_get_table
   sqlite_free_table   = _sqlite_free_table
   sqlite_mprintf   = _sqlite_mprintf
   sqlite_vmprintf   = _sqlite_vmprintf
   sqlite_exec_printf   = _sqlite_exec_printf
   sqlite_exec_vprintf    = _sqlite_exec_vprintf
   sqlite_get_table_printf   = _sqlite_get_table_printf
   sqlite_get_table_vprintf   = _sqlite_get_table_vprintf
   sqlite_freemem   = _sqlite_freemem
   sqlite_libversion   = _sqlite_libversion
   sqlite_libencoding   = _sqlite_libencoding
   sqlite_changes   = _sqlite_changes
   sqlite_create_function   = _sqlite_create_function
   sqlite_create_aggregate   = _sqlite_create_aggregate
   sqlite_function_type   = _sqlite_function_type
   sqlite_user_data   = _sqlite_user_data

   sqlite_aggregate_context   = _sqlite_aggregate_context
   sqlite_aggregate_count   = _sqlite_aggregate_count
   sqlite_set_result_string   = _sqlite_set_result_string
   sqlite_set_result_int   = _sqlite_set_result_int
   sqlite_set_result_double   = _sqlite_set_result_double
   sqlite_set_result_error   = _sqlite_set_result_error
   sqliteMalloc   = _sqliteMalloc
   sqliteFree   = _sqliteFree
   sqliteRealloc   = _sqliteRealloc
   sqlite_set_authorizer   = _sqlite_set_authorizer
   sqlite_trace   = _sqlite_trace
   sqlite_compile   = _sqlite_compile
   sqlite_step   = _sqlite_step
   sqlite_finalize   = _sqlite_finalize

8. Go to Project|Options|Directories/Conditionals. Add 'NO_TCL' to Conditional defines

9. Fire up the compiler.

10. Ready.

Mac OS X build

I used the standard Unix build instructions...

  $ tar xzf sqlite.tar.gz       Unpacks into directory named "sqlite"
  $ mkdir bld                   Create a separate build directory
  $ cd bld
  $ ../sqlite/configure --disable-shared
  $ make                        Builds "sqlite" and "libsqlite.a"
  $ make test                   Optional: run regression tests

But don't forget the implied

  $ make install

step! (if you are installing in /usr/local you might have to do this as root, e.g.: "sudo make install")

The --disable-shared option is required for Mac OS X because libtool is busted and will generate an invalid shared library.

The usability of the sqlite shell is greatly enhanced if you have readline support. If you install GNU readline first, sqlite will link to it automatically. Note that sqlite doesn't search in the fink (/sw) hierachy by default, so if you want to use fink readline you'll probably have to use compilation flags to point the configure script to /sw/lib and /sw/include/readline as well as adding /sw/lib to the DYLD_LIBRARY_PATH environment (WARNING: NOT TESTED!). Instead of doing this it might be easier just to install readline in the default location under /usr/local (readline 5 installs without a hiccough using the regular .configure; make; make install).

* Under AIX 4.3.3 with gcc *

  fmedico <at>

  mkdir sqlite
  cd sqlite
  unzip ../
  rm tclsqlite.c libsqlite.a sqlite 2> /dev/null
  for i in *.c; do gcc -g -O2 -c $i; done
  rm shell.o
  ar cr libsqlite.a *.o
  ranlib libsqlite.a
  gcc -o sqlite shell.c libsqlite.a


1. Run configure

2. edit src/os.h, go to ~ line 90 (behind the #ifndef OS_UNIX block) and add ala mingw solution above

   #define OS_WIN 1
   #define OS_MAC 0
   #define OS_UNIX 0

A similar change has already been checked into the CVS tree and should appear with release 2.8.6.

In 2.8.13 an extra slash passed to libtool caused me some trouble installing on cygwin. Removing each occurance of $(DESTDIR)/ from Makefile did the trick. There were eight, all in the install section. This var is handy for distributions, so probably don't want to remove.


This assumes you're a C++ type who likes Haven't gotten into the tcl interface, so the C_SOURCES variable bears inspection.

  Acquire boost, and boost jam.
  Navigate to <boost path>/libs
  mkdir sqlite
  cd sqlite
  mkdir src
  mkdir build
  cd src
  <unzip the sqlite source code here>
  cd ../build
  <save the following text as Jamfile>
  #  (C) Copyright  2002. Permission to copy, use, modify, sell and
  #  distribute this software is granted provided this copyright notice appears
  #  in all copies. This software is provided "as is" without express or implied
  #  warranty, and with no claim as to its suitability for any purpose.
  # Boost.sqlite build
  # To run all tests quietly: jam test
  # Declares the following targets:
  #   1. sqlite, a library to be linked with all
  #      Boost.sqlite modules
  # declare the location of this subproject relative to the root
  subproject libs/sqlite/build ;

  # Base names of the source files for libboost_sqlite
  C_SOURCES = attach auth     btree   btree_rb build
              copy   delete   expr    func     hash
              insert main     opcodes os       pager
              parse  pragma   printf  random   select
              table  tokenize trigger vdbe     where
              update util     vacuum
  EXE_ONLY  = shell

  dll sqlite : ../src/$(C_SOURCES).c
      : <sysinclude>$(BOOST_ROOT)
      : debug release

  lib sqlite : ../src/$(C_SOURCES).c
      : <sysinclude>$(BOOST_ROOT)
      : debug release

  exe sqlite       : ../src/$(C_SOURCES).c ../src/$(EXE_ONLY).c
      : <sysinclude>$(BOOST_ROOT)
      : debug release

Now you can just build sqlite along with the rest of boost. Tested on VC7.1 and GCC 3.3.1. Boost jam builds debug, release, static, and dynamically linked targets with a lack of fuss and bother.

AIX 5.2 with large file support

I used the IBM compiler xlc with specific cflags to build SQLite 2.8.7. AIX uses a slightly different define to enable 64 bit I/O in the system headers _LARGE_FILES. SQLite expects _LARGE_FILE, so I define both flags. The final two flags are -q32 which builds as a 32 bit application and -qlonglong, which enables the long long datatype.

Here are the steps I used:


edit Makefile, change the TCC macro:

     TCC = xlc -q32 -qlonglong  -D_LARGE_FILE=1 -D_LARGE_FILES=1 -DUSE_TCL_STUBS=1 -O2


Tom Poindexter 2003-12-17

Building a statically linked libtclsqlite

I use SQLite as part of a Starkit-based application. See and http://

In assembling a Starkit for Linux, one problem is incompatibility between different verions of glibc (e.g. RedHat 7.2 using glibc2.2, RedHat 8.0 using glibc2.3). There is a static build of tclkit for linux that avoids this problem by statically linking all libraries. I wanted the SQLite extension for Tcl to have the same feature.

Here are steps to build a statically linked Tcl extension:

First, make sure that the -DUSE_TCL_STUBS=1 macro is defined in your TCC makefile macro. We will be linking manually, so if using gcc, get the path to the libgcc.a for your installation:

   gcclib=`gcc -print-libgcc-file-name`

Add the following lines to your SQLite Makefile:

   echo '' >>Makefile
   echo '       tclsqlite.lo $(LIBOBJ)' >>Makefile
   echo "          ld -shared -soname  -o *.o -L/usr/local/lib -ltclstub8.4
-static -ldl -lm -lc  $gcclib" >>Makefile

Note that a tab should be inserted a the first character of the second line. Adjust your path to your Tcl install if not /usr/local/lib in order to find libtclstub8.4.a. Now build:


Tom Poindexter 2003-12-17

[ ULTRIX/VAX 4.4 ]

I successfully got Sqlite 2.8.13 to compile under ULTRIX/VAX 4.4 (4.x should work fine, not sure about earlier versions).

SQLite would NOT compile with VAX C, I had to install GCC and GNU make. There are binary packages out there for GCC 3.0.4 and GNU MAKE floating around on the net.

After setting the CC and CPP environment variables to the location of GCC (in my case it was /usr/ freeware/gnu-tools/vax/bin/gcc) and the preprocessor, SQLite compiled out of the box, just run configure, then GNU make (stock BSD make will NOT work!) and it will chew on it for a couple hours (hey, it's still a VAX), and in theory you should have working Ultrix SQLite.

NOTE: Remember, Ultrix has no support for shared libraries, if you want to use SQLite in an application, you have to compile sqlite in as a static library. This goes for TCL as well, you have to recompile TCL with and compiled smack inline.

No, I don't have any benchmarks unfortunately. It would be funny to benchmark SQLite against the University Ingres QUEL DBMS that ships with Ultrix on the UNSUPPORTED software distribution on the CD/TK50 tape/whatever else Ultrix shipped on.

My configuration:

DEC VAXserver 3100 m30 w/ 16MB/RAM, 1.6GB disk space. ULTRIX 4.4/VAX GCC 3.0.4 GNU MAKE

Have fun.

Kevin D. Ogden 19 APR 2004 E-Mail: ogdenk REPLACE-WITH-CORRECT-CHARACTER

Compiling SQLite with MS VC++ 5 for C newbies

This is a step-by-step procedure for those like me who wish to recompile SQLite and the "VB Wrapper" by Steve O'Hara to make this DLL VB-friendly. Note that I don't remember much from my C days, so should any kind soul spot any error, please add your corrections:

  1. Install MS VC++
  2. File | New | Projects : Choose Win32 DLL, and give a name to your new project. It will be saved in its own subdirectory under "\Program Files\DevStudio\MyProjects\". Choose the name carefully as it will be the one used to generate the DLL
  3. Unzip the SQLite source code into this directory (Caution: I understand that there are two versions of the source code. One is the most generic, ie. not meant for a particular OS, while one source package has been massaged, ready to be compiled by MS VC++. Choose the latter)
  4. Project | Add to project | Files, navigate to the folder where your project lives and now contains the SQLite source files, and select all its C files to have them added to your project (Note: To remove a file from a project, select it once with the mouse, and hit the DEL key. There is no option in the menu, either the application's or the pop-up's)
  5. If you have no use for TCL (a scripting language), remove tclsqlite.c
  6. Build | Set Active Configuration, and select "My project - Win32 Release" so we generate a plain DLL, with no debug infos
  7. If you wish to add version information so you get a Version tab when right-clicking on the DLL in Windows Explorer, select Project | Add to project | New : Resource Script. A clear-text res.rc is added to the project that you can edit to include version information (I haven't found how to have the version be incremented automatically.) Note that this version info embedded by VC++ is independent from the version info returned by sqlite_libversion(), ie. don't worry about the fact that the former is a four-digit number, while the latter uses three
  8. Build | Rebuild All. You'll see plenty of warnings, but if all goes well, you should now have a DLL in a Release/ subdirectory in your project directory

If you wish to use Steve O'Hara's free VB wrapper ("VB Wrapper", ex-psvbutls32 in the Files section of the now dead SQLite mailing list over at Yahoo), just add its source file pssql.c and its export file pssql.def to your project, edit the DEF file so that the LIBRARY line matches the name of your DLL (or you'll get a warning), and build the DLL.

Note that pssql.c assumes that the SQLite source code is located in a sqlite/ subdirectory, so either create a subdirectory to host the SQLite source files, or edit this file to have all the C files in the same directory. If the DEF file is missing, you'll get ""Runtime Error 453 Can't find DLL entry point PSVBUTLS_VersionDB in mysqlite.dll" when calling any of the wrapper's exported functions.

To check that this DLL works fine, create a new project in VB, add the following code in a form, and hit F5:

	Private Declare Function PSVBUTLS_VersionDB$ Lib "mysqlite.dll" ()

	Private Sub Form_Load()
	    Me.Caption = "SQLite version " & PSVBUTLS_VersionDB$
	End Sub

Voila! :-)


For 3.0.8 : On Solaris - to do what Tom did above - to create a without dependencies. The include and lib paths are somewhat hosed in the makefile - it somehow seems to need a source installation (/unix in path). I changed this in the Makefile:

   TCL_FLAGS = -I/usr/local/tcl/8.4.5/include -DUSE_TCL_STUBS
   LIBTCL    = /usr/local/tcl/8.4.5/lib/libtclstub8.4.a -ldl -lm


   % make

Copy the last line that is used to build the LA object. Remove all objects and libs and instead use *.o

   % gcc <flags including -o> .libs/*.o /usr/local/tcl/8.4.5/lib/libtclstub8.4.a  <other flags>

if you get an error remove .libs/tclsqlite3-sh.o

VI []


  You will find a step by step tutorial for beginners

  It shows how to build the SQLite library using the

  This tutorial is not posted in this wiki because it includes
  a lot of screenshots.


  You will find a step by step tutorial for beginners

  It shows how to build the SQLite library using the

  This tutorial is not posted in this wiki because it includes
  a lot of screenshots.