Cross compiling SQLite for ARM and MIPS

Following my blog entry about Databases for Linux Embedded Systems, here are the instructions to cross-compile SQlite.

First download the latest version of SQLite amalgamation with autoconf script (version 3.75):


Extract the source code:

tar xzvf sqlite-autoconf-3070500.tar.gz

Configure and build the source code. I’ll use mipsel-linux-gcc, but any other cross-compiler could be used.

cd sqlite-autoconf-3070500
./configure --host=mipsel-linux --target=mipsel-linux --prefix=/home/jaufranc/edev/sqlite-mips
make install

At this point the library is correctly configured and installed, so you’d just need to copy the relevant files to your target board (skip include and share directories and  libsqlite3.a) .

Let’s check the size of the required files:

ls -l ../sqlite-mips/bin/
-rwxr-xr-x 1 jaufranc jaufranc 125513 2011-03-14 14:21 sqlite

ls -l ../sqlite-mips/lib/
-rwxr-xr-x 1 jaufranc jaufranc 2087584 2011-03-14 14:21 ../sqlite-mips/lib/

sqlite binary is 122.57KB and the dynamic library 2038.65KB.

Let’s see if we can optimize the binary size with compilation flags and by disabling some unnecessary features.

The first thing to add is CFLAGS=”-Os” to your compilation flags as it will decrease the size by half.

Then if you don’t need it, you could disable R-Tree support (Remove -DSQLITE_ENABLE_RTREE in and Full Text Search (Remove -DSQLITE_ENABLE_FTS3  in which will save about 100KB extra.

Instead of using make install, type make install-strip to save more space as it would call mipsel-linux-strip.

Configure, build and install SQLite again:

./configure --host=mipsel-linux --target=mipsel-linux --prefix=/home/jaufranc/edev/sqlite-mips CFLAGS="-Os"
make install-strip

sqlite size is now 54.08KB and 595.34KB.

Share this:

Support CNX Software! Donate via cryptocurrencies, become a Patron on Patreon, or purchase goods on Amazon or Aliexpress

ROCK 5 ITX RK3588 mini-ITX motherboard
Notify of
The comment form collects your name, email and content to allow us keep track of the comments placed on the website. Please read and accept our website Terms and Privacy Policy to post a comment.
12 years ago

Hi there – thanks for this, but I think your code snippets fail to distinguish between ‘-‘ and ‘–‘; the latter seems to be encoded as a single character. For instance, your first bit of code should be something like:

./configure –host=mipsel-linux –target=mipsel-linux –prefix=/home/jaufranc/edev/sqlite-mips

./configure –host=mipsel-linux –target=mipsel-linux –prefix=/home/jaufranc/edev/sqlite-mips

12 years ago

aargh – your stylesheets or whatever are doing this to my comments as well!

should be ‘- -‘ (two normal dashes) not ‘–‘ (one em-dash)

Khadas VIM4 SBC