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.


Crosscompile linux x86 -> linux arm

1. Install skiff toolchain or similar, make shure 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; }; } #fi

. . .

#else # 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; }; }

. . .

#else # 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; }; }

. . .

#else # 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; }; }

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

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

6. run make Now you should find a “.libs” directory in your build directory containing sqlite shared object files, like libsqlite.so.

Source (somwhat altered): http://www.kecher.de/howtos/SQLite-JDBC-Howto.html