Geek Culture
Published in

Geek Culture

How to use SQLite databases while programming with C on BeagleBone Black or other ARM powered embedded devices

A practical introduction to SQLite with C, ARM, Eclipse IDE and Linux.

Landing

Recently, I have had a task to incorporate a SQLite database in a C application intended to run on Linux, and Poky/Yocto Project. The Yocto Project image runs on an ARM-powered device. For the task, I have had spent some time figuring out a practical step-by-step guide on building the SQLite libraries and executables to the ARM target architecture.

I share my findings, should you encounter similar issues and need guidance.

Step 1. Go install SQLite on the development machine

The development machine in my screenshots had the architecture x86–64 with an operating system Ubuntu 18.04.5 LTS . All screenshots are taken on the Ubuntu 18.04 version, but the actions stay similar on Ubuntu 20.04 LTS

Firstly update your existing packages

Step 2. Install the libsqlite3-dev package on development machine

This package allows the access to <sqlite3.h> header in the C programs you are writing .

Go beyond the usage of SQLite for applications meant for Linux desktop (x86) and use the embedded database in applications on your embedded devices (targeting the ARM architecture:e.g BeagleBone Black).

For that, you will need to compile the SQLite source code for the target architecture beforehand.

Step 3. Build the SQLite source code for the ARM architecture

When building a source code that invokes certain functions associated with sqlite for arm, you need to link to the version of sqlite3 libraries compiled for arm. By the way, during the current tutorial article I will be referring to SQLite3 which is its latest release.

Get SQLite .tar.gz source code from its official download page

I chose the directory ~/Compilers/ARM_SQLite to hold the content of the following actions.

Untar the .tar.gz package to extract source code

georgeca@georgeca-VirtualBox:~/Compilers/ARM_SQLite$ tar xvzf sqlite-autoconf-3160200.tar.gz


sqlite-autoconf-3160200/
sqlite-autoconf-3160200/compile
sqlite-autoconf-3160200/config.guess
sqlite-autoconf-3160200/configure
sqlite-autoconf-3160200/sqlite3ext.h
sqlite-autoconf-3160200/aclocal.m4
sqlite-autoconf-3160200/install-sh
sqlite-autoconf-3160200/depcomp
sqlite-autoconf-3160200/sqlite3.c
sqlite-autoconf-3160200/INSTALL
sqlite-autoconf-3160200/sqlite3.pc.in
sqlite-autoconf-3160200/missing
sqlite-autoconf-3160200/Makefile.am
sqlite-autoconf-3160200/config.sub
sqlite-autoconf-3160200/sqlite3.h
sqlite-autoconf-3160200/Makefile.in
sqlite-autoconf-3160200/README.txt
sqlite-autoconf-3160200/tea/
sqlite-autoconf-3160200/tea/configure
sqlite-autoconf-3160200/tea/aclocal.m4
sqlite-autoconf-3160200/tea/README
sqlite-autoconf-3160200/tea/tclconfig/
sqlite-autoconf-3160200/tea/tclconfig/install-sh
sqlite-autoconf-3160200/tea/tclconfig/tcl.m4
sqlite-autoconf-3160200/tea/doc/
sqlite-autoconf-3160200/tea/doc/sqlite3.n
sqlite-autoconf-3160200/tea/Makefile.in
sqlite-autoconf-3160200/tea/license.terms
sqlite-autoconf-3160200/tea/pkgIndex.tcl.in
sqlite-autoconf-3160200/tea/win/
sqlite-autoconf-3160200/tea/win/rules.vc
sqlite-autoconf-3160200/tea/win/makefile.vc
sqlite-autoconf-3160200/tea/win/nmakehlp.c
sqlite-autoconf-3160200/tea/generic/
sqlite-autoconf-3160200/tea/generic/tclsqlite3.c
sqlite-autoconf-3160200/tea/configure.ac
sqlite-autoconf-3160200/shell.c
sqlite-autoconf-3160200/Makefile.msc
sqlite-autoconf-3160200/sqlite3.1
sqlite-autoconf-3160200/ltmain.sh
sqlite-autoconf-3160200/Replace.cs
sqlite-autoconf-3160200/sqlite3.rc
sqlite-autoconf-3160200/configure.ac
georgeca@georgeca-VirtualBox:~/Compilers/ARM_SQLite$ ls -lh
total 2,4M
drwxr-xr-x 3 georgeca georgeca 4,0K ian 6 2017 sqlite-autoconf-3160200
-rw-rw-r-- 1 georgeca georgeca 2,4M feb 8 2017 sqlite-autoconf-3160200.tar.gz


******

Switch to ‘sqlite-autoconf-3160200’ subdirectory

georgeca@georgeca-VirtualBox:~/Compilers/ARM_SQLite$ cd sqlite-autoconf-3160200/

georgeca@georgeca-VirtualBox:~/Compilers/ARM_SQLite/sqlite-autoconf-3160200$ ls

aclocal.m4 config.guess configure depcomp install-sh Makefile.am Makefile.msc README.txt shell.c sqlite3.c sqlite3.h sqlite3.rc
compile config.sub configure.ac INSTALL ltmain.sh Makefile.in missing Replace.cs sqlite3.1 sqlite3ext.h sqlite3.pc.in tea

Configure for cross compilation on ARM Architecture

Parameters for the ‘configure’ command explained:

  • I will be using the Linaro cross toolchain for the compilation. I have already installed this toolchain at this path: /home/georgeca/Compilers/gcc-linaro-7.5.0–2019.12-x86_64_arm-linux-gnueabihf/

The parameters for the configure command explained:

  • host=arm-linux (set it like this)
  • prefix=/Compilers/SQLite_for_ARM (this is the directory where you intend to store SQLite3 artefacts after running the ‘make’ command)
  • CC=/home/georgeca/Compilers/gcc-linaro-7.5.0–2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc (This is the precise path to the C language cross-compiler on your toolchain)

Run the ‘configure’ command

georgeca@georgeca-VirtualBox:~/Compilers/ARM_SQLite/sqlite-autoconf-3160200$ ./configure --host=arm-linux --prefix=/Compilers/SQLite_for_ARM  CC=/home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc


checking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for arm-linux-strip... no
checking for strip... strip
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for arm-linux-gcc... /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... yes
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc accepts -g... yes
checking for /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc option to accept ISO C89... none needed
checking whether /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc understands -c and -o together... yes
checking dependency style of /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc... gcc3
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... 64
checking for arm-linux-gcc... (cached) /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc accepts -g... (cached) yes
checking for /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc option to accept ISO C89... (cached) none needed
checking whether /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc understands -c and -o together... (cached) yes
checking dependency style of /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc... (cached) gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... arm-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc... /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/bin/ld
checking if the linker (/home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... no
checking for arm-linux-dumpbin... no
checking for arm-linux-link... no
checking for dumpbin... no
checking for link... link -dump
configure: WARNING: using cross tools not prefixed with host triplet
checking the name lister (nm) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-unknown-linux-gnu file names to arm-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/bin/ld option to reload object files... -r
checking for arm-linux-objdump... no
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for arm-linux-dlltool... no
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for arm-linux-ar... no
checking for ar... ar
checking for archiver @FILE support... @
checking for arm-linux-strip... strip
checking for arm-linux-ranlib... no
checking for ranlib... ranlib
checking command to parse nm output from /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for arm-linux-mt... no
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc supports -fno-rtti -fno-exceptions... no
checking for /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc option to produce PIC... -fPIC -DPIC
checking if /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc PIC flag -fPIC -DPIC works... yes
checking if /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc static flag -static works... yes
checking if /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc supports -c -o file.o... yes
checking if /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc supports -c -o file.o... (cached) yes
checking whether the /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc linker (/home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/arm-linux-gnueabihf/bin/ld) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for fdatasync... yes
checking for usleep... yes
checking for fullfsync... no
checking for localtime_r... yes
checking for gmtime_r... yes
checking whether strerror_r is declared... yes
checking for strerror_r... yes
checking whether strerror_r returns char *... no
checking editline/readline.h usability... no
checking editline/readline.h presence... no
checking for editline/readline.h... no
checking readline/readline.h usability... no
checking readline/readline.h presence... no
checking for readline/readline.h... no
checking for library containing pthread_create... -lpthread
checking for library containing pthread_mutexattr_init... none required
checking for library containing dlopen... -ldl
checking for whether to support dynamic extensions... yes
checking for posix_fallocate... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating sqlite3.pc
config.status: executing depfiles commands
config.status: executing libtool commands

Run the ‘make’ command

georgeca@georgeca-VirtualBox:~/Compilers/ARM_SQLite/sqlite-autoconf-3160200$ make

/bin/bash ./libtool --tag=CC --mode=compile /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite\" -DPACKAGE_VERSION=\"3.16.2\" -DPACKAGE_STRING=\"sqlite\ 3.16.2\" -DPACKAGE_BUGREPORT=\"http://www.sqlite.org\" -DPACKAGE_URL=\"\" -DPACKAGE=\"sqlite\" -DVERSION=\"3.16.2\" -D_FILE_OFFSET_BITS=64 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DHAVE_POSIX_FALLOCATE=1 -I. -D_REENTRANT=1 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -g -O2 -MT sqlite3.lo -MD -MP -MF .deps/sqlite3.Tpo -c -o sqlite3.lo sqlite3.c
libtool: compile: /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite\" -DPACKAGE_VERSION=\"3.16.2\" "-DPACKAGE_STRING=\"sqlite 3.16.2\"" -DPACKAGE_BUGREPORT=\"http://www.sqlite.org\" -DPACKAGE_URL=\"\" -DPACKAGE=\"sqlite\" -DVERSION=\"3.16.2\" -D_FILE_OFFSET_BITS=64 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DHAVE_POSIX_FALLOCATE=1 -I. -D_REENTRANT=1 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -g -O2 -MT sqlite3.lo -MD -MP -MF .deps/sqlite3.Tpo -c sqlite3.c -fPIC -DPIC -o .libs/sqlite3.o

libtool: compile: /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite\" -DPACKAGE_VERSION=\"3.16.2\" "-DPACKAGE_STRING=\"sqlite 3.16.2\"" -DPACKAGE_BUGREPORT=\"http://www.sqlite.org\" -DPACKAGE_URL=\"\" -DPACKAGE=\"sqlite\" -DVERSION=\"3.16.2\" -D_FILE_OFFSET_BITS=64 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DHAVE_POSIX_FALLOCATE=1 -I. -D_REENTRANT=1 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -g -O2 -MT sqlite3.lo -MD -MP -MF .deps/sqlite3.Tpo -c sqlite3.c -o sqlite3.o >/dev/null 2>&1
mv -f .deps/sqlite3.Tpo .deps/sqlite3.Plo
/bin/bash ./libtool --tag=CC --mode=link /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -D_REENTRANT=1 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -g -O2 -no-undefined -version-info 8:6:8 -o libsqlite3.la -rpath /Compilers/SQLite_for_ARM/lib sqlite3.lo -ldl -lpthread
libtool: link: /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -shared -fPIC -DPIC .libs/sqlite3.o -ldl -lpthread -g -O2 -Wl,-soname -Wl,libsqlite3.so.0 -o .libs/libsqlite3.so.0.8.6
libtool: link: (cd ".libs" && rm -f "libsqlite3.so.0" && ln -s "libsqlite3.so.0.8.6" "libsqlite3.so.0")
libtool: link: (cd ".libs" && rm -f "libsqlite3.so" && ln -s "libsqlite3.so.0.8.6" "libsqlite3.so")
libtool: link: ar cru .libs/libsqlite3.a sqlite3.o
ar: `u' modifier ignored since `D' is the default (see `U')
libtool: link: ranlib .libs/libsqlite3.a
libtool: link: ( cd ".libs" && rm -f "libsqlite3.la" && ln -s "../libsqlite3.la" "libsqlite3.la" )
/home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite\" -DPACKAGE_VERSION=\"3.16.2\" -DPACKAGE_STRING=\"sqlite\ 3.16.2\" -DPACKAGE_BUGREPORT=\"http://www.sqlite.org\" -DPACKAGE_URL=\"\" -DPACKAGE=\"sqlite\" -DVERSION=\"3.16.2\" -D_FILE_OFFSET_BITS=64 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DHAVE_POSIX_FALLOCATE=1 -I. -D_REENTRANT=1 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_EXPLAIN_COMMENTS -g -O2 -MT sqlite3-shell.o -MD -MP -MF .deps/sqlite3-shell.Tpo -c -o sqlite3-shell.o `test -f 'shell.c' || echo './'`shell.c
mv -f .deps/sqlite3-shell.Tpo .deps/sqlite3-shell.Po
/home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -DPACKAGE_NAME=\"sqlite\" -DPACKAGE_TARNAME=\"sqlite\" -DPACKAGE_VERSION=\"3.16.2\" -DPACKAGE_STRING=\"sqlite\ 3.16.2\" -DPACKAGE_BUGREPORT=\"http://www.sqlite.org\" -DPACKAGE_URL=\"\" -DPACKAGE=\"sqlite\" -DVERSION=\"3.16.2\" -D_FILE_OFFSET_BITS=64 -DSTDC_HEADERS=1 -DHAVE_SYS_TYPES_H=1 -DHAVE_SYS_STAT_H=1 -DHAVE_STDLIB_H=1 -DHAVE_STRING_H=1 -DHAVE_MEMORY_H=1 -DHAVE_STRINGS_H=1 -DHAVE_INTTYPES_H=1 -DHAVE_STDINT_H=1 -DHAVE_UNISTD_H=1 -DHAVE_DLFCN_H=1 -DLT_OBJDIR=\".libs/\" -DHAVE_FDATASYNC=1 -DHAVE_USLEEP=1 -DHAVE_LOCALTIME_R=1 -DHAVE_GMTIME_R=1 -DHAVE_DECL_STRERROR_R=1 -DHAVE_STRERROR_R=1 -DHAVE_POSIX_FALLOCATE=1 -I. -D_REENTRANT=1 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_EXPLAIN_COMMENTS -g -O2 -MT sqlite3-sqlite3.o -MD -MP -MF .deps/sqlite3-sqlite3.Tpo -c -o sqlite3-sqlite3.o `test -f 'sqlite3.c' || echo './'`sqlite3.c
mv -f .deps/sqlite3-sqlite3.Tpo .deps/sqlite3-sqlite3.Po
/bin/bash ./libtool --tag=CC --mode=link /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -D_REENTRANT=1 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_EXPLAIN_COMMENTS -g -O2 -o sqlite3 sqlite3-shell.o sqlite3-sqlite3.o -ldl -lpthread
libtool: link: /home/georgeca/Compilers/gcc-linaro-7.5.0-2019.12-x86_64_arm-linux-gnueabihf/bin/arm-linux-gnueabihf-gcc -D_REENTRANT=1 -DSQLITE_THREADSAFE=1 -DSQLITE_ENABLE_FTS3 -DSQLITE_ENABLE_RTREE -DSQLITE_ENABLE_EXPLAIN_COMMENTS -g -O2 -o sqlite3 sqlite3-shell.o sqlite3-sqlite3.o -ldl -lpthread

Check the content of the libs directory inside ‘SQLite*’ directory

The libs directory is hidden (can be viewed with ls -lha) and it contains the libraries that need to be used when linking for ARM.

Read the ‘INSTALL’ document for information about installing the programs and documentation locally

The INSTALL file is located in the sqlite-autoconf-3160200 directory

Configure the package for your system using ‘configure’ command

georgeca@georgeca-VirtualBox:~/Compilers/ARM_SQLite/sqlite-autoconf-3160200$ ./configurechecking for a BSD-compatible install... /usr/bin/install -c
checking whether build environment is sane... yes
checking for a thread-safe mkdir -p... /bin/mkdir -p
checking for gawk... no
checking for mawk... mawk
checking whether make sets $(MAKE)... yes
checking whether make supports nested variables... yes
checking for style of include used by make... GNU
checking for gcc... gcc
checking whether the C compiler works... yes
checking for C compiler default output file name... a.out
checking for suffix of executables...
checking whether we are cross compiling... no
checking for suffix of object files... o
checking whether we are using the GNU C compiler... yes
checking whether gcc accepts -g... yes
checking for gcc option to accept ISO C89... none needed
checking whether gcc understands -c and -o together... yes
checking dependency style of gcc... gcc3
checking for special C compiler options needed for large files... no
checking for _FILE_OFFSET_BITS value needed for large files... no
checking for gcc... (cached) gcc
checking whether we are using the GNU C compiler... (cached) yes
checking whether gcc accepts -g... (cached) yes
checking for gcc option to accept ISO C89... (cached) none needed
checking whether gcc understands -c and -o together... (cached) yes
checking dependency style of gcc... (cached) gcc3
checking build system type... x86_64-unknown-linux-gnu
checking host system type... x86_64-unknown-linux-gnu
checking how to print strings... printf
checking for a sed that does not truncate output... /bin/sed
checking for grep that handles long lines and -e... /bin/grep
checking for egrep... /bin/grep -E
checking for fgrep... /bin/grep -F
checking for ld used by gcc... /usr/bin/ld
checking if the linker (/usr/bin/ld) is GNU ld... yes
checking for BSD- or MS-compatible name lister (nm)... /usr/bin/nm -B
checking the name lister (/usr/bin/nm -B) interface... BSD nm
checking whether ln -s works... yes
checking the maximum length of command line arguments... 1572864
checking how to convert x86_64-unknown-linux-gnu file names to x86_64-unknown-linux-gnu format... func_convert_file_noop
checking how to convert x86_64-unknown-linux-gnu file names to toolchain format... func_convert_file_noop
checking for /usr/bin/ld option to reload object files... -r
checking for objdump... objdump
checking how to recognize dependent libraries... pass_all
checking for dlltool... no
checking how to associate runtime and link libraries... printf %s\n
checking for ar... ar
checking for archiver @FILE support... @
checking for strip... strip
checking for ranlib... ranlib
checking command to parse /usr/bin/nm -B output from gcc object... ok
checking for sysroot... no
checking for a working dd... /bin/dd
checking how to truncate binary pipes... /bin/dd bs=4096 count=1
checking for mt... mt
checking if mt is a manifest tool... no
checking how to run the C preprocessor... gcc -E
checking for ANSI C header files... yes
checking for sys/types.h... yes
checking for sys/stat.h... yes
checking for stdlib.h... yes
checking for string.h... yes
checking for memory.h... yes
checking for strings.h... yes
checking for inttypes.h... yes
checking for stdint.h... yes
checking for unistd.h... yes
checking for dlfcn.h... yes
checking for objdir... .libs
checking if gcc supports -fno-rtti -fno-exceptions... no
checking for gcc option to produce PIC... -fPIC -DPIC
checking if gcc PIC flag -fPIC -DPIC works... yes
checking if gcc static flag -static works... yes
checking if gcc supports -c -o file.o... yes
checking if gcc supports -c -o file.o... (cached) yes
checking whether the gcc linker (/usr/bin/ld -m elf_x86_64) supports shared libraries... yes
checking whether -lc should be explicitly linked in... no
checking dynamic linker characteristics... GNU/Linux ld.so
checking how to hardcode library paths into programs... immediate
checking whether stripping libraries is possible... yes
checking if libtool supports shared libraries... yes
checking whether to build shared libraries... yes
checking whether to build static libraries... yes
checking for fdatasync... yes
checking for usleep... yes
checking for fullfsync... no
checking for localtime_r... yes
checking for gmtime_r... yes
checking whether strerror_r is declared... yes
checking for strerror_r... yes
checking whether strerror_r returns char *... no
checking editline/readline.h usability... no
checking editline/readline.h presence... no
checking for editline/readline.h... no
checking readline/readline.h usability... no
checking readline/readline.h presence... no
checking for readline/readline.h... no
checking for library containing pthread_create... -lpthread
checking for library containing pthread_mutexattr_init... none required
checking for library containing dlopen... -ldl
checking for whether to support dynamic extensions... yes
checking for posix_fallocate... yes
checking that generated files are newer than configure... done
configure: creating ./config.status
config.status: creating Makefile
config.status: creating sqlite3.pc
config.status: executing depfiles commands
config.status: executing libtool commands

Install programs, data file and documentation locally

georgeca@georgeca-VirtualBox:~/Compilers/ARM_SQLite/sqlite-autoconf-3160200$ sudo make install

make[1]: Entering directory '/home/georgeca/Compilers/ARM_SQLite/sqlite-autoconf-3160200'
/bin/mkdir -p '/usr/local/lib'
/bin/bash ./libtool --mode=install /usr/bin/install -c libsqlite3.la '/usr/local/lib'
libtool: install: /usr/bin/install -c .libs/libsqlite3.so.0.8.6 /usr/local/lib/libsqlite3.so.0.8.6
libtool: install: (cd /usr/local/lib && { ln -s -f libsqlite3.so.0.8.6 libsqlite3.so.0 || { rm -f libsqlite3.so.0 && ln -s libsqlite3.so.0.8.6 libsqlite3.so.0; }; })
libtool: install: (cd /usr/local/lib && { ln -s -f libsqlite3.so.0.8.6 libsqlite3.so || { rm -f libsqlite3.so && ln -s libsqlite3.so.0.8.6 libsqlite3.so; }; })
libtool: install: /usr/bin/install -c .libs/libsqlite3.lai /usr/local/lib/libsqlite3.la
libtool: install: /usr/bin/install -c .libs/libsqlite3.a /usr/local/lib/libsqlite3.a
libtool: install: chmod 644 /usr/local/lib/libsqlite3.a
libtool: install: ranlib /usr/local/lib/libsqlite3.a
libtool: warning: remember to run 'libtool --finish /Compilers/SQLite_for_ARM/lib'
/bin/mkdir -p '/usr/local/bin'
/bin/bash ./libtool --mode=install /usr/bin/install -c sqlite3 '/usr/local/bin'
libtool: install: /usr/bin/install -c sqlite3 /usr/local/bin/sqlite3
/bin/mkdir -p '/usr/local/include'
/usr/bin/install -c -m 644 sqlite3.h sqlite3ext.h '/usr/local/include'
/bin/mkdir -p '/usr/local/share/man/man1'
/usr/bin/install -c -m 644 sqlite3.1 '/usr/local/share/man/man1'
/bin/mkdir -p '/usr/local/lib/pkgconfig'
/usr/bin/install -c -m 644 sqlite3.pc '/usr/local/lib/pkgconfig'
make[1]: Leaving directory '/home/georgeca/Compilers/ARM_SQLite/sqlite-autoconf-3160200'

The sqlite executable file appears in the directory.

Step 4. Set up the Eclipse IDE for accessing the needed header files and the libraries when linking for ARM

Set up the cross compiler for the desired Building Configuration

This is needed so that Eclipse IDE can find the header files during the compilation step.

Set up the cross linker for the desired Building Configuration

This is needed so that Eclipse IDE can find the libraries it needs during the linking step.

Step 5. Set up Eclipse IDE to build source code that appeals to sqlite* functions on the Desktop (x86)

An example how to compile and link the C source code containing sqlite with commands

gcc name_of_program.c -o name_of_executable -lsqlite3

./name_of_executable

An example how to compile and link the C source code containing sqlite with Geany code editor

--

--

--

A new tech publication by Start it up (https://medium.com/swlh).

Recommended from Medium

Release notes 3.0.20 | Sylo Smart Wallet

Get Classroom Data into your Google Sheet using Google Apps Script

Star Date 10.30.2020… In a Galaxy Far, Far, Away…

A Simple Shop System for a Unity 2D Game — Part 2: UI Mechanics

Managing Moodle with Laravel Nova

Day 36 of 100 Days of VR: Getting Our FPS Game Running in VR

How To Make A Simple Dice Game In Python

Top Programming Languages to Learn in 2020

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
George Calin

George Calin

for 15 years mentoring people, providing ERP support, writing business intelligence reports, programming (business apps and embedded Linux).

More from Medium

How I learned Yocto Project and Qt and why you would do the same

Install NVIDIA CUDA on Linux

Raspberry Pi and Embedded Linux Adventure (PART1: How to Start)

Using the Lua Programming Language to Create a Graphical User Interface