Small. Fast. Reliable.
Choose any three.

Page History

Turn Off History

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 http://www.sqlite.org/sqlite_source.zip. 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:

  unzip sqlite_source.zip
  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


To get it compiling on DJGPP (DOS) you need to patch src/os.c with the following (unified diff):

	--- ../temp/sqlite/src/os.c	2002-10-20 20:16:50.000000000 +0000
	+++ src/os.c	2002-12-24 18:31:16.000000000 +0000
	@@ -27,6 +27,10 @@
	 # include <winbase.h>
	 #endif

	+#if (!defined __DJGPP__) && (!defined O_BINARY)
	+#define O_BINARY 0
	+#endif
	+
	 /*
	 ** Macros for performance tracing.  Normally turned off
	 */
	@@ -232,9 +236,9 @@
	   int *pReadonly
	 ){
	 #if OS_UNIX
	-  id->fd = open(zFilename, O_RDWR|O_CREAT, 0644);
	+  id->fd = open(zFilename, O_RDWR|O_CREAT|O_BINARY, 0644);
	   if( id->fd<0 ){
	-    id->fd = open(zFilename, O_RDONLY);
	+    id->fd = open(zFilename, O_RDONLY|O_BINARY);
	     if( id->fd<0 ){
	       return SQLITE_CANTOPEN; 
	     }
	@@ -306,7 +310,7 @@
	 #ifndef O_NOFOLLOW
	 # define O_NOFOLLOW 0
	 #endif
	-  id->fd = open(zFilename, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW, 0600);
	+  id->fd = open(zFilename, O_RDWR|O_CREAT|O_EXCL|O_NOFOLLOW|O_BINARY, 0600);
	   if( id->fd<0 ){
	     return SQLITE_CANTOPEN;
	   }
	@@ -359,7 +363,7 @@
	 */
	 int sqliteOsOpenReadOnly(const char *zFilename, OsFile *id){
	 #if OS_UNIX
	-  id->fd = open(zFilename, O_RDONLY);
	+  id->fd = open(zFilename, O_RDONLY|O_BINARY);
	   if( id->fd<0 ){
	     return SQLITE_CANTOPEN;
	   }
	@@ -682,9 +686,13 @@
	     lock.l_type = F_RDLCK;
	     lock.l_whence = SEEK_SET;
	     lock.l_start = lock.l_len = 0L;
	+#ifdef __DJGPP__
	+    {
	+#else
	     if( fcntl(id->fd, F_SETLK, &lock)!=0 ){
	       rc = SQLITE_BUSY;
	     }else{
	+#endif
	       rc = SQLITE_OK;
	       id->pLock->cnt = 1;
	       id->locked = 1;
	@@ -736,9 +744,13 @@
	     lock.l_type = F_WRLCK;
	     lock.l_whence = SEEK_SET;
	     lock.l_start = lock.l_len = 0L;
	+#ifdef __DJGPP__
	+    {
	+#else
	     if( fcntl(id->fd, F_SETLK, &lock)!=0 ){
	       rc = SQLITE_BUSY;
	     }else{
	+#endif
	       rc = SQLITE_OK;
	       id->pLock->cnt = -1;
	       id->locked = 1;
	@@ -798,9 +810,13 @@
	     lock.l_type = F_UNLCK;
	     lock.l_whence = SEEK_SET;
	     lock.l_start = lock.l_len = 0L;
	+#ifdef __DJGPP__
	+    {
	+#else
	     if( fcntl(id->fd, F_SETLK, &lock)!=0 ){
	       rc = SQLITE_BUSY;
	     }else{
	+#endif
	       rc = SQLITE_OK;
	       id->pLock->cnt = 0;
	     }

This is needed, because files need to be explicitely opened in binary mode and the check for locking always fails in DJGPP.

DJGPP: http://www.delorie.com/djgpp


MSVC and SQLite DLL

Creation of an import library from the sqlitedll.zip (http://www.sqlite.org/sqlitedll.zip) for MS Visual C++ is achieved by the following command:

	LIB /DEF:sqlite.def

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