linux sqlite 静态库

转载 2011年01月11日 20:05:00

原文出处 http://wenku.baidu.com/view/aa48ea7931b765ce0508145c.html

免费下载连接

http://xz.qjwm.com/down.aspx?down=ok&filepath=dante300%2f%ba%c3%b5%c4%b5%e7%d7%d3%ca%e9%2fsqlite-3.3.6arm-linux-gcc.pdf

----------------------- Page 1-----------------------

1、在Redhat Linux9 上用arm-linux-gcc编译成功sqlite-3.3.6 静态库版本。

2、在Redhat Linux9 上用arm-linux-gcc编译成功基于sqlite3 静态库的应用程序。

Compile SQLite using the cross-compiler such as arm-linux-gcc

first, get sqlite-3.3.6.tar.gz from www.sqlite.org

unzip it,

#tar -zxvf sqlite-3.3.6.tar.gz

change into the sqlite-3.3.6 directory

cd sqlite-3.3.6

make a new directory such as 'build' under sqlite-3.3.6 directory,

open the configure-script using your favorite text-editor ,such as:

#vi configure

I recomamnd that you make a copy of configure before editing the configure file

cp configure configure.old

and edit the configure.

Comment out the following commands by putting a '#' in front of them(looks like):

#if test "$cross_compiling" = "yes"; then

# { { echo "$as_me:$LINENO:: 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:$LINENO:: 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 &&

----------------------- Page 2-----------------------

# { { echo "$as_me:$LINENO:: 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; }; }

Save the configure script, change into the build directory you created and call the edited configure script from the sqlite

directory by using the following option:

../sqlite/configure --disable-tcl --host=arm-linux

After that configure should have created a Makefile and a libtool script in your build directory.

Open the Makefile using your favorite text editor and find the following lines:

BCC = arm-linux-gcc -g -O2

change to

BCC = gcc -g -O2

The reason for these changes is that the created files have to be executed on the PC during the compilation, so we have to

compile them with the standard gcc and not the arm-linux-gcc.

if you want compile static library version of sqlite3(only one execute file for distribution) on ARM, edit Makefile ,

find

sqlite3$(TEXE): $(TOP)/src/shell.c .libs/libsqlite3.la sqlite3.h

change to

sqlite3$(TEXE): $(TOP)/src/shell.c .libs/libsqlite3.a sqlite3.h

find

-o $@ $(TOP)/src/shell.c .libs/libsqlite3.la /

change to

-o $@ $(TOP)/src/shell.c .libs/libsqlite3.a /

save and quit editor

run 'make' command to create the sqlite3 execute file, after a successful compile,Now you should find a hiden “.libs”

directory in your build directory containing sqlite shared object files, like libsqlite.so or static libray files like

libsqlite3.a .

run 'arm-linux-strip sqlite3' to decrease the execute file size.

upload the sqlite3 to target ARM9 board by any FTP client and make it executive:

----------------------- Page 3-----------------------

on ARM9 board with terminal or telnet ,run

chmod 775 sqlite3

and then run sqlite3 like this

sqlite3 ex2

,if you see the following messages:

SQLite version 3.3.6

Enter ".help" for instructions

sqlite>

input some commands to do something,

sqlite> create table tbl(one varchar(10),two smallint);

sqlite> insert into tbl values('hello',10);

sqlite> insert into tbl values('goodbye',20);

sqlite> .quit

more commands , please visit www.sqlite.org for details

then use 'ls ex2' to list files in currect directory,

if you see 'ex2' file,

congratulations,you have successfully making a standalone 'sqlite3'.

next step we should compile the example code on www.sqlite.org's quickstart page

make a 'test.c' file in 'build' directory, content as showed:

#include <stdio.h>

#include "sqlite3.h" /* orignal is <sqlite3.h> */

static int callback(void *NotUsed, int argc, char **argv, char **azColName){

int i;

for(i=0; i<argc; 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 ){

----------------------- Page 4-----------------------

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;

}

save and quit editor,

#arm-linux-gcc test.c -L.libs -lsqlite3 -static

explaination: -L.libs show that the lib searching path is '.libs'

'-lsqlite3 -static' show that the lib name is libsqlite3.a,the 'lib' and '.a' is added by linker.

with the above command ,we can compile a standalone application with sql databse supported.

use arm-linux-strip to decrease its size:

arm-linux-strip a.out

upload to ARM9 board, make it runable and test it:

[root@fa fa]# a.out ex "select * from tbl"

one = hello

two = 10

one = goodbye

two = 20

[root@fa fa]#

if you see the above result , ok you make it.

over.

wish the article is usefull for you!

相关文章推荐

SQLITE3静态库

  • 2010-03-27 21:50
  • 2.25MB
  • 下载

sqlite3 c++ API 静态库

  • 2017-05-12 11:19
  • 997KB
  • 下载

VS2015编译SQLite3 动态链接库DLL和静态库Lib

SQLite是一款简单易用的轻量级数据库,相关优势请自行查阅资料,本文主要使用VS2015编译动态链接库Dll和静态库lib。 SQLite官网:http://sqlite.org/index.ht...

Sqlite3加密静态库

  • 2011-10-30 13:14
  • 1.28MB
  • 下载

编译iOS上可用的sqlite3静态库

前言 之前的文章提到如何使用NDK编译Android上的sqlite3的动态库文件,今天因为第一天上班,人还有点恍惚。早上因为要送老婆去火车站,所以很早便出门了,后来到单位才7点一刻左右,悲催的是单位...
  • Sozell
  • Sozell
  • 2013-10-08 21:48
  • 2492

linux pthread libc静态库

  • 2013-09-05 14:02
  • 1.45MB
  • 下载

opencv 2.4.13 静态库 for linux

  • 2016-12-13 17:11
  • 20.50MB
  • 下载

linux下的C语言开发(静态库)

【原文:http://blog.csdn.net/feixiaoxing/article/details/7202472】 【 声明:版权所有,欢迎转载,请勿用于商业用途。  联系信箱:feixia...

linux下lua5.2.0静态库

  • 2017-08-25 21:43
  • 685KB
  • 下载
内容举报
返回顶部
收藏助手
不良信息举报
您举报文章:深度学习:神经网络中的前向传播和反向传播算法推导
举报原因:
原因补充:

(最多只允许输入30个字)