嵌入式数据库sqlite移植教程
sqlite-3.3.6编译安装与交叉编译全过程详细记录
本文介绍的内容都是基于 linux redhat 9.0 平台的。
一、pc机编译安装
请阅读在安装包里的 install 文件。或者使用pear installer with pear install sqlite。sqlite已经内置了,你不需要安装任何附加的软件(additional software)。
windows users可以下载sqlite扩展dll(php_sqlite.dl)。
这里简单介绍一下:
假设你得到的是源代码sqlite-3.3.6.tar.gz,这里将告诉你怎么编译它。
解压sqlite-3.3.6.tar.gz 到 /home目录下
for example:
tar zxvf sqlite-3.3.6.tar.gz -c /home
cd /home
mkdir sqlite-ix86-linux
cd /home/sqlite-ix86-linux/
../sqlite-3.3.6/configure --prefix=/home/sqlite-ix86-linux/
编译并安装,然后生成帮助文档
make && make install && make doc
如果出现下列错误
../sqlite-3.3.6/src/tclsqlite.c: in function `dbupdatehandler'''''''':
../sqlite-3.3.6/src/tclsqlite.c:333: warning: passing arg 3 of `tcl_listobjappendelement'''''''' makes pointer from integer without a cast
../sqlite-3.3.6/src/tclsqlite.c: in function `tclsqlfunc'''''''':
../sqlite-3.3.6/src/tclsqlite.c:419: warning: passing arg 1 of `tcl_newbytearrayobj'''''''' discards qualifiers from pointer target type
这个都是tcl相关的错误,可以先安装activetcl以解决.假如你不需要tcl支持,那么这个错误可以这样避免:
cd /home/sqlite-ix86-linux/
../sqlite-3.3.6/configure --disable-tcl --prefix=/home/sqlite-ix86-linux/
编译并安装,然后生成帮助文档
make && make install && make doc
不出意外,将不会出现错误,那么
库文件已经生成在 /home/sqlite-ix86-linux/lib 目录下
可执行文件sqlite3已经生成在 /home/sqlite-ix86-linux/bin 目录下
下面创建一个新的数据库文件名叫zieckey.db (当然你可以使用不同的名字) 来测试数据库.
直接输入: /home/sqlite-ix86-linux/bin/sqlite3 test.db
如果出现下面字样表明编译安装已经成功了.
sqlite version 3.3.6
enter .help for instructions
sqlite>
二、交叉编译sqlite.3.3.6.tar.gz库文件
tar zxvf sqlite-3.3.6.tar.gz -c /home (这一步前面已经有了,为了完整性,这里还是写出来)
mkdir /home/sqlite-arm-linux
设置交叉编译环境
export path=/usr/local/arm-linux/bin:$path
cd /home/sqlite-arm-linux/
../sqlite-3.3.6/configure --disable-tcl --prefix=/home/sqlite-arm-linux/ --host=arm-linux
这步出现错误而没有生成makefile
configure: error: unable to find a compiler for building build tools
前面检查arm-linux-gcc都通过了,怎么还说没有找到编译器呢?花了点时间看configure的脚本,太复杂了,又结合configure.ac看了一下。原来是要设置config_target_cc和config_build_cc两个环境变量。config_target_cc是交叉编译器,config_build_cc是主机编译器。重来:
export config_build_cc=gcc
export config_target_cc=arm-linux-gcc
../sqlite-3.3.6/configure --disable-tcl --prefix=/home/sqlite-arm-linux/ --host=arm-linux
又出现如下错误
checking for /usr/include/readline.h... configure: error: cannot check for file existence when cross compiling
说readline.h的错,找到readline.h在/usr/include/readline/readline.h目录,我想这样解决
ln -s /usr/include/readline/readline.h /usr/include/readline.h
但还是不行
../sqlite-3.3.6/configure --disable-tcl --prefix=/home/sqlite-arm-linux/ --host=arm-linux
还是出现如下同样的错误
checking for /usr/include/readline.h... configure: error: cannot check for file existence when cross compiling
上面说是要检查交叉编译环境,我可以肯定我的交叉编译环境是正确的,
所以我决定欺骗configure,我是这样做的
cd /home/sqlite-3.3.6
将该目录下的 configure 文件的部分内容修改下(这里是根据 test $cross_compiling = yes && 找到的 ),
这样可以让configure不去检查你的交叉编译环境。
20420行 { (exit 1); exit 1; }; }改为 { (echo 1); echo 1; }; }
20446行 { (exit 1); exit 1; }; }改为 { (echo 1); echo 1; }; }
在回去重新配置下:
cd /home/sqlite-arm-linux/
../sqlite-3.3.6/configure --disable-tcl --prefix=/home/sqlite-arm-linux/ --host=arm-linux
中间打印信息出现如下错误信息,
checking for /usr/include/readline.h... configure: error: cannot check for file existence when cross compiling
但是还是生成了makefile文件一个libtool脚本,这些将在make时用到.
注意:
如果makefile文件中有如下语句
bcc = arm-linux-gcc -g -o2
请将其改掉,改成:
bcc = gcc -g -o2
将下面的这行
sqlite3$(text):$(top)/src/shell.c libsqlite3.la sqlite3.h
改成
sqlite3$(text):$(top)/src/shell.c .libs/libsqlite3.a sqlite3.h
因为运行时都是将sqlite放到arm-linux的硬件板子上运行,所以一般将其编译成静态链接的形式。
编译并安装
make && make install
这里如果不出意外,将不会出现错误,那么库文件已经生成在 /home/sqlite-ix86-linux/lib 目录下 好了,就到这里。
sqlite-3.3.17交叉编译说明
1、在redhat linux9上用arm-linux-gcc编译成功sqlite-3.3.17静态库版本。
2、在redhat linux9上用arm-linux-gcc编译成功sqlite-3.3.17动态库版本。
3、在redhat linux9上用arm-linux-gcc编译成功基于sqlite3静态库的应用程序。
4、在redhat linux9上用arm-linux-gcc编译成功基于sqlite3动态库的应用程序。
//==================================================================
//compile sqlite using the cross-compiler such as arm-linux-gcc
1. first, get sqlite-3.3.17.tar.gz from www.sqlite.org
2. unzip it
#tar -zxvf sqlite-3.3.17.tar.gz
3. change into the sqlite-3.3.17 directory
cd sqlite-3.3.17
4. make a new directory such as ''''''''build'''''''' under sqlite-3.3.17 directory,
mkdir sqlite-arm-linux
5. first,please ensure the cross compiler arm-linux-gcc included in path,
use ''''''''echo $path'''''''',you can look out the path,
if no,set the path:
export path=/usr/local/arm/2.95.3/bin:$path
6. 3.3.17版本的configure和makefile都不需改动
7. change into the build directory you created
cd sqlite-arm-linux
8. call the edited configure script from the sqlite directory by using the following option:
../configure --disable-tcl --host=arm-linux
9. after that configure should have created a makefile and a libtool script in your build directory.
10. run ''''''''make'''''''' command to create the sqlite3 execute file, after a successful compile
11. now you should find a hiden “.libs” directory in your build directory containing sqlite shared object files,
like libsqlite3.so or static libray files like libsqlite3.a .
12. use ''''''''file sqlite3'''''''' to look the inf of sqlite3, run ''''''''arm-linux-strip sqlite3'''''''' to decrease the execute file size.
13. upload the sqlite3 to target arm9 board by any ftp client and make it executive:
14. on arm9 board with terminal or telnet ,run
chmod 775 sqlite3
15. and then run sqlite3 like this
sqlite3 ex2
16. ,if you see the following messages:
sqlite version 3.3.17
enter .help for instructions
sqlite>
在arm-linux平台上移植sqlite
1、软硬件平台
本文中采用的硬件平台为sitsang嵌入式评估板。sitsang评估板的核心是pxa255嵌入式处理器。底层软件系统是以arm-linux内核为基础的。
要将sqlite3移植到sitsang评估板上,除了要有底层操作系统的支持外,还必须要有相应的交叉编译工具链。由于sitsang评估板采用的是arm-linux作为底层操作系统,因此需要首先安装arm-linux工具链。关于arm-linux工具链的安装可以参阅文献[4]。arm-linux工具链通常安装在/usr/local/arm-linux/bin/目录下,通常以arm-linux-开头。本文中将会涉及到的主要是arm-linux-gcc、arm-linux-ar、arm-linux-ranlib这样三个工具。
2、移植过程
首先从http://sqlite.org下载sqlite 3.4.2。本文中假设将sqlite-3.4.2.tar.gz下载到/home/liyan/sqlite目录下。然后,通过下列命令解压缩sqlite-3.4.2.tar.gz并将文件和目录从归档文件中抽取出来:
# tar zxvf sqlite-3.4.2.tar.gz
解压抽取完成之后将会在/home/liyan/sqlite目录下生成一个sqlite-3.4.2/子目录,在该目录中包含了编译所需要的所有源文件和配置脚本。sqlite3的所有源代码文件都位于sqlite-3.4.2/src/目录下。
和在pc环境下编译sqlite3不同,不能通过sqlite-3.4.2/目录下的configure脚本来生成makefile文件。取而代之的是必须手动修改makefile文件。在sqlite-3.4.2/目录下有一个makefile范例文件makefile.linux-gcc。首先通过下面的命令拷贝此文件并重命名为makefile:
# cp makefile.linux-gcc makefile
接下来,用vim打开makefile文件并手动修改makefile文件的内容。首先找到makefile文件中的下面这样一行:
top = ../sqlite 将其修改为:top = .
找到下面这样一行:tcc = gcc -o6 将其修改为:tcc = arm-linux-gcc -o6
找到下面这样一行:ar = ar cr 将其修改为:ar = arm-linux-ar cr
找到下面这样一行:ranlib = ranlib将其修改为:ranlib = arm-linux-ranlib
找到下面这样一行:mkshlib = gcc -shared 将其修改为:mkshlib = arm-linux-gcc -shared
注释掉下面这一行:tcl_flags = -i/home/drh/tcltk/8.4linux
注释掉下面这一行:libtcl = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl
vi中的查找方法:在命令模式下输入“?”加要查找的字符串,再回车。输入“n”为查找下一处。
原则上,对makefile的修改主要包括两个方面:首先是将编译器、归档工具等换成交叉工具链中的对应工具,比如,gcc换成arm-linux-gcc,ar换成ar-linux-ar,ranlib换成arm-linux-ranlib等等;其次是去掉与tcl相关的编译选项,因为默认情况下,将会编译sqlite3的tcl语言绑定,但是在移植到arm-linux的时候并不需要,因此将两个与tcl有关的行注释掉。
接下来,还需要修改的一个的文件是main.mk,因为makefile包含了这个文件。找到这个文件中的下面一行:select.o table.o tclsqlite.o tokenize.o trigger.o把它替换成:select.o table.o tokenize.o trigger.o
也就是把该行上的tclsqlite.o去掉。这样编译的时候将不会编译sqlite3的tcl语言绑定。
自此,修改工作就完成了,接下来就可以开始编译sqlite3了,这通过make命令即可完成:
# make
编译完成之后,将在sqlite3.4.2/目录下生成库函数文件libsqlite3.a和头文件sqlite3.h,这就是所需要的两个文件了。
3、测试
这里以sqlite官方站点http://sqlite.org的quick start文档中的测试程序为例对移植到arm-linux上的sqlite3进行测试。该程序清单如下:
#include
#include
static int callback(void *notused, int argc, char **argv, char **azcolname)
{
int i;
for(i=0; i
{
printf(%s = %s\n, azcolname[i], argv[i] ? argv[i] : null);
}
printf(\n);
return 0;
}
int main(int argc, char **argv)
{
sqlite3 *db;
char *zerrmsg = 0;
int rc;
if( argc!=3 )
{
fprintf(stderr, usage: %s database sql-statement\n, argv[0]);
exit(1);
}
rc = sqlite3_open(argv[1], &db);
if( rc )
{
fprintf(stderr, can''''''''t open database: %s\n,sqlite3_errmsg(db));
sqlite3_close(db);
exit(1);
}
rc = sqlite3_exec(db, argv[2], callback, 0, &zerrmsg);
if( rc!=sqlite_ok )
{
fprintf(stderr, sql error: %s\n, zerrmsg);
sqlite3_free(zerrmsg);
}
sqlite3_close(db);
return 0;
}
将此源程序保存为test.c,然后,通过如下命令编译该程序:
# arm-linux-gcc -i /home/liyan/sqlite/sqlite-3.4.2 -l /home/liyan/sqlite/sqlite-3.4.2 -o test test.c -lsqlite3
注意:可能会出现以下错误
/home/liyan/sqlite/sqlite-3.4.2/libsqlite3.a(os_unix.o)(.text+0x3ec): in function `sqlite3unixdlopen'''''''':
: undefined reference to `dlopen''''''''
/home/liyan/sqlite/sqlite-3.4.2/libsqlite3.a(os_unix.o)(.text+0x3f4): in function `sqlite3unixdlsym'''''''':
: undefined reference to `dlsym''''''''
/home/liyan/sqlite/sqlite-3.4.2/libsqlite3.a(os_unix.o)(.text+0x3f8): in function `sqlite3unixdlclose'''''''':
: undefined reference to `dlclose''''''''
collect2: ld returned 1 exit status
解决方法:在编译命令后加 “-ldl”
# arm-linux-gcc -i /home/liyan/sqlite/sqlite-3.4.2 -l /home/liyan/sqlite/sqlite-3.4.2 -o test test.c -lsqlite3 -ldl
上述编译命令中:
-i /home/liyan/sqlite/sqlite-3.4.2指明了头文件sqlite3.h所在的目录;
-l /home/liyan/sqlite/sqlite-3.4.2指定了库函数文件libsqlite3.a所在的目录;
-o test指定编译生成的文件名为test,test.c是源程序文件;
-lsqlite3指明要链接静态库文件libsqlite3.a。
编译完成后,可以通过nfs将test下载到sitsang评估板上,通过ls命令可以看到test的大小只有300k左右:
[root@ee301 sqlite]# ls -l test
-rwxr-xr-x 1 root root 359148 09-03 13:22 test
接下来就可以测试test程序了。test程序接受两个参数:第一个参数为数据库文件名,第二个参数为要执行的sql语句。程序中与sqlite3的api相关的地方主要有四个:sqlite3_open(), sqlite3_exec(), sqlite3_close(), sqlite3_free()。关于sqlite3的api接口请参阅文献[1]。
下面是测试test程序的完整过程,(在板子上):
/var/tmp/ly # ./test xyz.db create table tbl0(name varchar(10), number smallint);
/var/tmp/ly # ./test xyz.db insert into tbl0 values(''''''''cyc'''''''', 1);
/var/tmp/ly # ./test xyz.db insert into tbl0 values(''''''''dzy'''''''', 2);
/var/tmp/ly # ./test xyz.db select * from tbl0;
name = cyc
number = 1
name = dzy
number = 2
解释一下上面所用的测试命令:
第一条命令在xyz.db这个数据库文件中创建了一个tbl0表,表中包含两个字段,字段name是一个变长字符串,字段number的类型为smallint;
第二条命令向数据库的tbl0表中插入了一条记录(‘cyc’,1);
第三条命令向数据库的tbl0表中插入了一条记录(‘dzy’,2);
第四条命令则是查询表tbl0中的所有内容,与预期的一样,这条命令打印除了数据库中的两条刚插入的记录。
由此可以得出结论,这几条命令确实都已经按照预期的目标工作了。
同时,在向数据库中插入上面所示的数据之后,可以看到数据库文件xyz.db大小已经发生了变化:
/var/tmp/ly # ls -l test
-rw-r--r-- 1 root root 2048 sep 3 2007 xyz.db
此时数据库文件xyz.db的大小为2k。自此,sqlite3数据库在sitsang评估板上移植完成。测试结果表明数据库能够正常工作。
参考文献
[1] the definitive guide to sqlite。[美]michael owens著。apress,2006
[2] http://sqlite.org
[3] sqlite移植手记。hily jiang。www.sqlite.com.cn,2006年11月
[4] sitsang/pxa255 evaluation platform linux user’s guide。intel ltd,sep. 2003
*主要参考*[5] 在arm-linux平台上移植sqlite,
sqlite嵌入式数据库在arm-linux下的编译全攻略
sqlite嵌入式数据库在arm-linux下的编译全攻略 [原创] 2004-06-02
作者:余涛(yut616_at_sohu.com)
第一步 sqlite在arm-linux下的编译
1、 下载sqlite:请到http://www.sqlite.org/download.html,将下载的代码包解开,将生成sqlite目录,另外新建一个build目录,如sqlite-arm-linux,应该是和sqlite目录平行的同级目录。
2、 请先确定你的path中已经包含交叉编译工具arm-linux-gcc。可用“echo $path”命令查看。如我的是“/opt/toolchain/gcc 3.2/toolchain/bin/”
3、 为了在arm-linux下能正常运行sqlite,我们需要修改一处代码,否则在arm板上运行sqlite时会出现下面的东东:
===============================
在文件btree.c中抛出断言,
assert( sizeof(ptr)==sizeof(char*) );
===============================
此断言是为了保证btree(b树)有正确的变量大小,如“ptr”和“char*”。 在不同的体系结构的linux,如x86和arm,会有些差别。刚好让我们在arm-linux下遇到了:-)。那么我们可以做一定的修改。
请修改sqlite/src/sqliteint.h,找到如下部分:
#ifndef intptr_type
# if sqlite_ptr_sz==4
# define intptr_type int
# else
# define intptr_type long long
# endif
在上面的代码前加上一句:
#define sqlite_ptr_sz 4
这样后面的“typedef intptr_type ptr;”就是定义的“int”类型,而不是“long long”。
4、 准备使用configure进行一些配置。请在sqlite目录下的configure中找到如下4处,并将他们注释掉,这样可以让configure不去检查你的交叉编译环境。在此提示一下:请你自己确定自己的“arm-linux-”系列命令在你的path环境变量中。如:你可以输入“arm-linux-”再按“tab”键,看其是否自动完成命令行。
#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; }; }
注释掉后,就可以执行configure了。在sqlite-arm-linux目录下,输入如下命令:
../sqlite/configure --host=arm-linux
这样在你的build目录中就将生成makefile和一个libtool脚本,这些将在make时用到。
5、 修改makefile文件
请修改makefile文件,将下面的这行
bcc = arm-linux-gcc -g -o2
改掉,改成:
bcc = gcc -g -o2
一般地,我们都是将sqlite放到arm-linux的硬件板子上运行,所以我们一般将其编译成静态链接的形式。如果是共享so库的话,比较麻烦。
所以继续修改makefile,找到如下地方:
sqlite:
将有其后的“libsqlite.la”改成
“.libs/libsqlite.a”
大功告成,现在可以make了。
应该不会出错,生成sqlite,libsqlite.a,libsqlite.so。你可以使用命令:find -name sqlite;find -name *.a;find -name *.so查
看文件所在的目录。
此时生成的sqlite文件是还未strip过的,你可以使用命令“file sqlite”查看文件信息。用strip处理过后,将去掉其中的调试信息,执行文
件大小也将小很多。命令如下:
arm-linux-strip sqlite
第二步 在arm板上运行sqlite
将sqlite拷贝到你的arm板上,方法很多,你需要根据自己的情况来选择。如ftp,cmdftp,wget等。
我的方法是使用wget将sqlite下载到arm板的/tmp目录,此目录是可写的。命令如下:
busybox wget ftp://192.168.0.100/sqlite
上面的命令,你可以看到我的板子上是已经有busybox来支持wget命令了的。:-)
好,开始运行
chmod +wx sqlite
./sqlite test.sqlite
会出现
sqlite>
提示符号,打个“.help”来看看命令先:-)
sqlite>.help
好了。现在sqlite已经在arm-linux下跑了起来。如何,感觉不错吧,在arm板子上玩玩“select * from”语句蛮爽吧:-)
友情提示:
如果sqlite在处理数据库过程中出现“the database disk image is malformed”,如:你在delete from sometable时,可能遇到这个问题。
那么就是你的arm板上的空间不够(如在/tmp下),请删除掉一些文件。我遇到的情况是空间还剩1-2m都会出现这个提示。删除后空余4m,就正
常了(如delete from sometable)。我是开的8m的ramdisk做开发玩的:-)
谢谢阅读。
欢迎转载,但请写明出处。
undefined reference to dlsym
1) i checked out the code to directory called sqlite
2) i modified the makefile.in to allow loading
extensions. we have to comment the following line
#tcc += -dsqlite_omit_load_extension=1
3) created a directory called build. ran configure and make from there.
4) i get undefined refernce to dlsym, dlopen, dlclose error.
apparently the problem is with sqlite failing to find dynamic linker
library. i added ldflags to command line before running make
like this: ldflags=-ldl make. still it fails.
please tell me what is the error.
you''''''''ll end up with a makefile (and several other files) in this directory. edit this mmakefile and comment out the line:
tcc += -dsqlite_omit_load_extension=1
i found this to be necessary to avoid errors later when i compile the shell.c (the sqlite3 clp).
you may also what to edit the line tlibs = to read
tlibs = -ldl
now do the following to compile and install:
~/dev/build$ make
after the make you will have a directory full of object files and the sqlite clp executable called sqlite3
~/dev/build$ sudo make install
new libraries will be installed as /usr/local/lib/libsqlite3.a and /usr/local/lib/libsqlite3.so.0.8.6 (the former being the static lib and the later the shared lib). the sqlite3 executable is also installed in /usr/local/bin/.
now make the amalgamated sqlite source file:
~/dev/build$ make sqlite3.c
you end up with a very large source file sqlite3.c and the header sqlite3.h which are essentially what you need to embed sqlite in your applications. you also have individual source files under the ~/dev/build/tsrc/. you will also find shell.c here - this is the source used to build the clp.
to build the clp using shared library:
~/dev/build$ gcc -o2 -o sqlite3 tsrc/shell.c -ldl -lsqlite3
note that -lpthread is not required since shell.c does not require it.
you''''''''ll end up with a 39k sqlite3 executable file.
to build the clp with the sqlite embedded:
~/dev/build$ gcc -o2 -o sqlite3 tsrc/shell.c sqlite3.c -ldl -lpthread
i end up with and executable of just under 380k size. note that -lpthread needs to be specified since sqlite3.c uses it (i think).
i''''''''m not sure how the static library can be used. when i try
~/dev/build$ gcc -o2 -o sqlite3 tsrc/shell.c -ldl -lpthread -l:libsqlite3.a
i end up with an executable of 1.4mb in size. it still works but i think it''''''''s not right
when cross-compiling sqlite-3.4.0, i encounter this linkage error:
./.libs/libsqlite3.s undefined reference to `dlclose''''''''
./.libs/libsqlite3.s undefined reference to `dlopen''''''''
./.libs/libsqlite3.s undefined reference to `dlsym''''''''
the solution:
===========
i added in makefile.in the -ldl at the end of the line.
----
sqlite3$(texe): $(top)/src/shell.c libsqlite3.la sqlite3.h
$(ltlink) $(readline_flags) $(libpthread) \
-o $@ $(top)/src/shell.c libsqlite3.la \
$(libreadline) $(tlibs) -ldl
my configure command is:
--------------------------------------
./configure
''''''''--build=i686-linux'''''''' \
--host=powerpc-wrs-linux-gnu \
--prefix=/usr/local \
''''''''--disable-tcl'''''''' \
''''''''--disable-debug'''''''' \
''''''''--with-gnu-ld'''''''' \
''''''''--enable-threadsafe'''''''' \
''''''''--enable-releasemode'''''''' \
--disable-static
sqlite 移植到arm-linux
不过他们用的sqlite版本相对都要老一些,有很多说明已经不太实用。以下引用yeshi的文章,来自http://blog.chinaunix.net/u/16292/showart_149594.html:
首先在http://www.sqlite.org/download.html上下载sqlite-3.3.13.tar.gz
$ tar -zxvf sqlite-3.3.13.tar.gz ~/sqliteforuclinux/
$ cd sqliteforuclinux/sqlite-3.3.13
查看readme,内容为:
for example:
tar x*** sqlite.tar.gz ;# unpack the source tree into sqlite
mkdir bld ;# build will occur in a sibling directory
cd bld ;# change to the build directory
../sqlite/configure ;# run the configure script
make ;# run the makefile.
make install ;# (optional) install the build products
我们现在要做的是交叉编译,要是为本机编译,可以照做就可以了
$ mkdir bld
$ cd bld
export config_build_cc=gcc
export config_target_cc=arm-linux-gcc
修改bld/目录下的 configure 文件的部分内容
20420行 { (exit 1); exit 1; }; }改为 { (echo 1); echo 1; }; }
20446行 { (exit 1); exit 1; }; }改为 { (echo 1); echo 1; }; }
$ ../sqlite-3.3.13/configure --disable-tcl --prefix=/home/yeshi/sqliteforuclinux/bld --host=arm-linux
将/bld/makefile文件中如下语句
bcc = arm-linux-gcc -g -o2
改成:
bcc = gcc -g -o2 //红色字体的是上面贴子上的,我的不用改的,已经是bcc = gcc -g
(我的也已经不需要改)
$make
$make install
bld/lib 目录下,
库文件已经生成在为了减小执行文件大小可以用strip处理,去掉其中的调试信息。
arm-linux-strip libsqlit3.so.0
在这个过程中起先遇到了不认识编译器的问题,修改环境变量解决问题,而这个文章中没有提到的是link tag的问题,要修改一下makefile文件,把 --tag=arm-linux放到libtool字段的link段的后面,去掉$(tcc),或者在$(tcc)之前空一格然后添上--tag=cc
践行合作创新,爱立信携手中国移动等伙伴以意图驱动自智网络项目斩获TMF最佳创新与未来技术国际大奖
最强配置之下,vivoXplay6磨砂黑新款拍照表现令人意外
将声学研发成果及前沿工程科技凝于耳边方寸之间
一文汇总ADI移动医疗全体征监测方案
学PLC需要什么基础?PLC编程入门怎么学?
嵌入式数据库Sqlite移植教程
慧翰股份创业板IPO受理!TBOX连续五年降价,募资7.13亿研发5G车联网TBOX
机器人产业报告解读:工业类忙着向上延伸 服务类加速生态构建
基于NXP 74LVCV2G66评估板的电路原理图
张晨卸任,随着“技术”被提上了日程,京东比以往更需要一个合适的CTO
是德科技与新思科技共同合作,支持台积电N6RF设计参考流程
一枚小传感器撬动千亿级产业集群,这里如何实现“弯道超车”?
市面上的无人机反制类型都有哪些
谷歌将挑战苹果Siri,确保行业领头羊
三相变压器励磁涌流的特点是什么?
集微连线:板级封装潜力无穷 RDL工艺勇挑大梁
石墨烯/氮化硼异质结构在集成电路热管理中的应用
一个新的、大型的机器人指南网站,了解世界上最酷的机器人
HP MSA存储vxfs文件系统数据恢复案例
碳化硅太阳能电池的湿式化学处理