虚拟机上linux版本:CentOS release 6.7 (Final) 开发板:FL2440 内核:linux-3.0
虚拟机linux上执行
1.首先到http://www.sqlite.org/download.html下载linux版本的源码:sqlite-autoconf-3140100.tar.gz
2.自己选择个路径新建文件夹sqlite-arm-linux
[zzx@localhost 3rdparty]$ mkdir sqlite-arm-linux
[zzx@localhost 3rdparty]$ cd sqlite-arm-linux/
3.将下载好的文件传到该目录下,并解压缩
[zzx@localhost sqlite-arm-linux]$ ls
sqlite-autoconf-3140100.tar.gz
[zzx@localhost sqlite-arm-linux]$ tar -zxf sqlite-autoconf-3140100.tar.gz
[zzx@localhost sqlite-arm-linux]$ ls
sqlite-autoconf-3140100 sqlite-autoconf-3140100.tar.gz
4.进入解压缩后的文件目录下,新建install文件夹,以存放后来生成的lib库函数和可执行文件
[zzx@localhost sqlite-arm-linux]$ cd sqlite-autoconf-3140100
[zzx@localhost sqlite-autoconf-3140100]$ ls
aclocal.m4 depcomp Makefile.msc sqlite3.c
compile INSTALL missing sqlite3ext.h
config.guess install-sh README.txt sqlite3.h
config.sub ltmain.sh Replace.cs sqlite3.pc.in
configure Makefile.am shell.c sqlite3.rc
configure.ac Makefile.in sqlite3.1 tea
[zzx@localhost sqlite-autoconf-3140100]$ mkdir install
[zzx@localhost sqlite-autoconf-3140100]$ cd install
5.进入install目录下,用pwd获取绝对路径,然后退出到上一层
[zzx@localhost install]$ pwd
/home/zzx/fl2440/3rdparty/sqlite-arm-linux/sqlite-autoconf-3140100/install
[zzx@localhost install]$ cd ..
6.使用configure配置文件如下
[zzx@localhost sqlite-autoconf-3140100]$ ./configure --prefix=/home/zzx/fl2440/3rdparty/sqlite-arm-linux/sqlite-autoconf-3140100/install --host=arm-linux CC=/opt/buildroot-2012.08/arm920t/usr/bin/arm-linux-gcc
注:CC赋值为嵌入式开发环境所使用的交叉编译工具,后面接自己交叉编译器的路径 , --host指定软件运行环境为arm-linux, --prefix指定源码交叉编译后生成文件的路径,我们指向了刚才新建的install文件夹
7.make和make install,查看是否生成以下文件
[zzx@localhost sqlite-autoconf-3140100]$ make
[zzx@localhost sqlite-autoconf-3140100]$ make install
[zzx@localhost sqlite-autoconf-3140100]$ cd install
[zzx@localhost install]$ ls
bin include lib share
[zzx@localhost install]$ cd bin/
[zzx@localhost bin]$ ls
sqlite3
[zzx@localhost bin]$ ls ../lib/
libsqlite3.a libsqlite3.so libsqlite3.so.0.8.6
libsqlite3.la libsqlite3.so.0 pkgconfig
8.将sqlite3 libsqlite3.so libsqlite3.so.0.8.6 libsqlite3.so.0打包上传PC端,以便使用tftp从PC端传到开发板
[zzx@localhost bin]$ cp sqlite3 ../lib/
[zzx@localhost bin]$ cd ../lib/
[zzx@localhost lib]$ ls
libsqlite3.a libsqlite3.so libsqlite3.so.0.8.6 sqlite3
libsqlite3.la libsqlite3.so.0 pkgconfig
[zzx@localhost lib]$ tar -zcvf sqlite3.tar.gz libsqlite3.so* sqlite3
libsqlite3.so
libsqlite3.so.0
libsqlite3.so.0.8.6
sqlite3
[zzx@localhost lib]$ ls
libsqlite3.a libsqlite3.so.0 sqlite3
libsqlite3.la libsqlite3.so.0.8.6 sqlite3.tar.gz
libsqlite3.so pkgconfig
[zzx@localhost lib]$ sz sqlite3.tar.gz
开发板上执行
9.使用tftp,将文件包传从PC端传输到开发板上,解压缩,并将libsqlite3.so libsqlite3.so.0.8.6 libsqlite3.so.0 放到/lib/路径下,将sqlite3 放到/bin/路径下
>: tftp -gr sqlite3.tar.gz 192.168.1.2
sqlite3.tar.gz 100% |*******************************| 2302k 0:00:00 ETA
>: tar -zxf sqlite3.tar.gz
>: mv libsqlite3.so* /lib/
>: mv sqlite3 /bin/
10.测试是否移植成功,直接输入sqlite3,如下
>: sqlite3
SQLite version 3.14.1 2016-08-11 18:53:32
Enter ".help" for usage hints.
Connected to a transient in-memory database.
Use ".open FILENAME" to reopen on a persistent database.
注:编译程序 需要加上 -l sqlite3 这个链接选项
**********************************************************************
出现上述问题时,是我最开始做时交叉编译器的问题,得用arm-linux-gcc编译,原来我直接用的在电脑上sqlite的解压缩包是用gcc编译的,后来我重新解压缩,按上述步骤操作成功
*********************************************************************
OK!!!