0. PrefaceThis blog post may not have much use value. But practice for practice. There are many ways to use SQLite on Raspberry Pi, and there are many ways to install it. "1" assumes that Python is used, so you don't have to install SQLite because Python has its own sqlite.
"2" can be installed using Apt-get. Only the version of SQLite is slightly lower. "3" can be installed using the source code, directly compiled on the Raspberry Pi, although the Raspberry Pi computing speed than the PC. But wait a few minutes can also compile the installation finished. "4" Suppose you want to practice cross-compiling, read the following.
"The purpose of this article " "1" how to cross-compile the source package "2" cross-compile the resulting file where "3" cross-compiled files should be copied to the Raspberry Pi where "4" Learn more about Linux knowledge.
"Reference material" "1" Raspberry Pi Study notes-cross-compilation Toolchain "2" Linux learning notes-how to use shared Library "3" Linux learning notes during cross-compilation--Example of Makefile Index blog post
1. Cross-compilation process"1" Get the source codeDownload the SQLite source package and unzip it in the free user folder. "SQLite Download Link" July 2014 the latest SQlite3 source package name is sqlite-autoconf-3080500.tar.gz."2" Create a new folderCreate a new directory Opt/sqlite-rpi in the user directory. This directory is used to store files that are obtained after cross-compilation mkdir-p Opt/sqlite-rpi
"3" Write an installation scriptIn the SQLite source folder, add an installation script--user-install-rpi.sh
#!/bin/bash./configure cc=arm-linux-gnueabihf-gcc--host=arm-linux--prefix= $HOME/opt/sqlite-rpi && make Clean && make && make install
"description" "a" CC=ARM-LINUX-GNUEABIHF-GCC specifies the cross tool chain. The tool chain has been written to the user environment variable. "B"--host=arm-linux Specify the Host "C"--prefix= $HOME/opt/sqlite-rpi Specify the installation file path, and step "1" corresponding to "D" && representative run the next instruction. \ represents the continuation of the line.
"4" to run cautiouslyChange the permissions for the file to run. and run the script
chmod user-install-rpi.sh./user-install-rpi.sh
"6" ResultsIn the Opt/sqlite-rpi folder, there are 4 subfolders, including the SQLite executable file in "Bin", the interface API for SQLite in "include", including the dynamic in the Sqlite3.h and Sqlite3ext.h "Lib" folders. Shared library libsqlite3.so.0.8.6 and static shared libraries libsqlite3.a
2. Copy to Raspberry PiThe detailed location of these files in the Raspberry Pi can vary. This example simply points out the most frequently used location (the default location for Linux lookups). However, files such as dynamic shared libraries and header files can be located in a random folder in the Raspberry Pi. Just want you to be able to find it correctly in the process of compiling and running.
"1" uses FTP software to upload sqlite3 (executable files), libsqlite3.so.0.8.6 (dynamic link library), sqlite3.h and sqlite3ext.h to the Raspberry Pi.
"2" SQLite can run files, copy to/bin folder in sudo cp sqlite3/bin/"3" libsqlite3.so.0.8.6, copy to/lib folder in sudo cp libsqlite3.so.0. 8.6/lib/"4" Sqlite3.h and Sqlite3ext.h copied to the/usr/include/folder, if you use this C language API, then these two header files must be (and of course can be placed in other folders.) Just look for success when you're makefile. sudo cp sqlite3.h sqlite3ext.h/usr/include/"5" If the console runs Sqlite3 error occurs, check if there is a repeat libsqlite3.so.0.8.6.
Repeated dynamic shared libraries may be added when Python is installed. sudo find-name/libsqlite3.so "Run results"#1/usr/lib/arm-linux-gnueabihf/libsqlite3.so.0.8.6#2 /lib/libsqlite3.so.0.8.6 "Cover # # #" Please change the CP command parameters according to the actual search results.
sudo cp/lib/libsqlite3.so.0.8.6/usr/lib/arm-linux-gnueabihf/
"5" execution sqlite3, successful execution
SQLite version 3.8.5 2014-06-04 14:06:34enter ". Help" for usage hints. Connected to a transient in-memory database. Use ". Open FILENAME" to reopen on a persistent database.sqlite>
3. Summary"1" cross-compiling is still inseparable from make three strides, configure, make and make install.
"2" after cross-compilation of the resulting files copied to the Linux default find folder, such as/usr/lib//usr/include/. "3" Please be patient when encountering problems.
Raspberry Pi Study notes-SQLite3 installation of cross-compilation exercises