?? uclinux-sqlite.txt
字號(hào):
RANLIB = $(CROSS)ranlib
#RANLIB = /opt/mingw/bin/i386-mingw32-ranlib
#### Extra compiler options needed for programs that use the TCL library.
#
#TCL_FLAGS =
#TCL_FLAGS = -DSTATIC_BUILD=1
#TCL_FLAGS = -I/home/drh/tcltk/8.4linux
#TCL_FLAGS = -I/home/drh/tcltk/8.4win -DSTATIC_BUILD=1
#TCL_FLAGS = -I/home/drh/tcltk/8.3hpux
#### Linker options needed to link against the TCL library.
#
#LIBTCL = -ltcl -lm -ldl
#LIBTCL = /home/drh/tcltk/8.4linux/libtcl8.4g.a -lm -ldl
#LIBTCL = /home/drh/tcltk/8.4win/libtcl84s.a -lmsvcrt
#LIBTCL = /home/drh/tcltk/8.3hpux/libtcl8.3.a -ldld -lm -lc
#### Compiler options needed for programs that use the readline() library.
#
READLINE_FLAGS =
#READLINE_FLAGS = -DHAVE_READLINE=1 -I/usr/include/readline
#### Linker options needed by programs using readline() must link against.
#
#LIBREADLINE =
#LIBREADLINE = -static -lreadline -ltermcap
#### Should the database engine assume text is coded as UTF-8 or iso8859?
#
# ENCODING = UTF8
ENCODING = ISO8859
# You should not have to change anything below this line
###############################################################################
include $(TOP)/main.mk
===========Makefile內(nèi)容結(jié)束===========
注:
1、 在uclinux下的sqlite的Makefile將不去用到TCL相關(guān)的庫。
2、 在uclinux下的sqlite的Makefile將不去用到readline()。
在sqlite/README中有關(guān)于Makefile的一段描述:
The configure script uses autoconf 2.50 and libtool. If the configure script does not work out for you, there is a generic makefile named "Makefile.linux-gcc" in the top directory of the source tree that you can copy and edit to suite your needs. Comments on the generic makefile show what changes are needed.
你可以用sqlite/Makefile.linux-gcc作為藍(lán)本來修改適合你自己的Makefile。
你如果有興趣的話,可以把上面的Makefile的內(nèi)容和sqlite/Makefile.linux-gcc內(nèi)容diff對比一下,看看uclinux下的sqlite編譯有哪些不同的地方。
三、修改sqlite/src/os.c
如果你的sqlite包中包括os.c文件那么就對其進(jìn)行修改,沒有os.c文件可能是你的sqlite版本比較新,那么無須修改。
將所有你找到的:
if( s!=0 )
用:
if( s!=0 && errno != ENOSYS )
替換。
四、修改sqlite/src/shell.c
1、struct previous_mode_data 結(jié)構(gòu)定義項(xiàng):
將 int colWidth[100];
用 int colWidth[20];
替換。
2、struct callback_data 結(jié)構(gòu)定義項(xiàng)
將:
int colWidth[100];
int actualWidth[100];
char outfile[FILENAME_MAX];
用:
int colWidth[20];
int actualWidth[20];
char *outfilep;
對應(yīng)替換。
再在結(jié)構(gòu)下面增加:
#ifndef FILENAME_MAX
#define FILENAME_MAX 4095
#endif
char outfilename[FILENAME_MAX]; /* Filename for *out */
即
struct callback_data
{
...
};
#ifndef FILENAME_MAX
#define FILENAME_MAX 4095
#endif
char outfilename[FILENAME_MAX]; /* Filename for *out */
3、函數(shù)do_meta_command(...)
找到類似這樣的一句:
sqlite_exec(p->db, "PRAGMA database_list; ", callback, &data, &zErrMsg);
在它的前面有一句
memcpy(&data, p, sizeof(data));
現(xiàn)在在memcpy下面增加一行
data.cnt = 0;
即將結(jié)構(gòu)中cnt的值賦為0 ;
現(xiàn)在代碼會(huì)被修改成類似:
open_db(p);
memcpy(&data, p, sizeof(data));
data.cnt = 0;
再繼續(xù)。
找到類似這樣的一句:
strcmp(azArg[1],"stdout")==0
在它的下面的括號(hào)中:
將 strcpy(p->outfile,"stdout");
用 p->outfilep = "stdout";
來替換。
再在它下面的5-6行處
將:
strcpy(p->outfile,azArg[1]);
用:
strcpy(outfilename,azArg[1]);
p->outfilep = outfilename;
替換。
再繼續(xù),找到類似這樣的一句:
fprintf(p->out,"%9.9s: %s\n","output",
將:
fprintf(p->out,"%9.9s: %s\n","output", strlen(p->outfile) ? p->outfile : "stdout");
用:
fprintf(p->out,"%9.9s: %s\n","output", p->outfilep && strlen(p->outfilep) ? p->outfilep : "stdout");
替換。
完成修改。
上面的所有的對sqlite的修改完成后,你就可以make dep;make lib_only;make user_only;make romfs;make image了。
如果你對sqlite 的修改,在make user_only過程中出現(xiàn)錯(cuò)誤的話,你可以忽略make dep;make lib_only命令,直接再次進(jìn)行make user_only;make romfs;make image;就可以了,而不用重復(fù)make dep;make lib_only。
make image會(huì)幫你生成romfs文件系統(tǒng)。現(xiàn)在在uClinux-dist/images下面就有編譯生成的romfs文件系統(tǒng)了。這個(gè)就是我們需要的包含有sqlite的romfs了。
在上面的過程中,你可以不用在“make image”后再去“make”生成kernel內(nèi)核,因?yàn)槟阒恍枰蓃omfs就可以了,它里面已經(jīng)有sqlite了。
現(xiàn)在你就可以把你生成的含有sqlite應(yīng)用程序的romfs下載到開發(fā)板上運(yùn)行一下。
Welcome to
____ _ _
/ __| ||_|
_ _| | | | _ ____ _ _ _ _
| | | | | | || | _ \| | | |\ \/ /
| |_| | |__| || | | | | |_| |/ \
| ___\____|_||_|_| |_|\____|\_/\_/
| |
|_|
GDB/ARMulator support by
For further information check:
Command:>www.uclinux.org/
Command: /bin/ifconfig eth0 up 10.0.0.2
Execution Finished, Exiting
init: Booting to single user mode
Sash command shell (version 1.1.1)
/> cd bin
/bin> ls -l sqlite
-rwxr-xr-x 1 0 0 327072 Jan 01 00:00 sqlite
/bin >cd /tmp
/tmp>sqlite test.sqlite
sqlite> create table my(name varchar(80), num smallint);
sqlite> insert into my values('yutao', 100);
sqlite> insert into my values('uclinux', 99);
sqlite> select * from my;
yutao|100
uclinux|99
sqlite> .tables
my
sqlite> .schema
create table my(name varchar(80), num smallint);
sqlite> .q
/tmp>ls –l test.sqlite
你要保證你的/tmp是可寫的目錄。
好,現(xiàn)在你的sqlite就已經(jīng)在uclinux運(yùn)行起來了,感覺怎么樣呀,在uclinux也可以玩玩“select * from”,感覺很爽吧。
?? 快捷鍵說明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -