当前位置:   article > 正文

linux3.6.7在ok6410平台的移植3,s3c6410下移植sqlite3.7.8

linux 移植sqlite3 -sh: sqlite: command not found

http://blog.chinaunix.net/uid-30441-id-2133838.html

1、下载源代码http://www.sqlite.org/download.html

2、tar -zxvf sqlite-amalgamation-3.6.23.1.tar.gz

3、进入sqlite-3.6.23.1

4、mkdir build

5、cd build

6、../configure --host=arm-linux --prefix=/usr/local/sqlite3

注意:使用arm-linux-gcc 3.4.5时出现如下错误

checking for C compiler default output file name...

configure: error: C compiler cannot create executables

See `config.log' for more details.

怀疑没有写权限,使用如下配置通过

sudo ../configure --host=arm-linux --prefix=/usr/local/sqlite3

移植到开发板上无法运行,使用下面配置

../configure --host=arm-unknown-linux-gnu --prefix=/usr/local/sqlite3

7、make

出现问题:

arm-none-linux-gnueabi-gcc: 3.6.23.1": No such file or directory

: warning: missing terminating " character

^Cmake: *** [sqlite3.lo] 错误 1

解决:

Makefile中

-DPACKAGE_STRING="sqlite 3.6.23.1"

改为:

-DPACKAGE_STRING="sqlite_3.6.23.1"

8、sudo make install

出现问题:

arm-linux-ranlib /usr/local/sqlite3/lib/libsqlite3.a

./libtool: line 6619: arm-linux-ranlib: command not found

make[1]: *** [install-libLTLIBRARIES] 错误 127

make[1]:正在离开目录 `/work/development/sqlite/sqlite-3.6.23.1/build'

make: *** [install-am] 错误 2

原因:root权限的时候没有设置arm-linux 的PATH

解决:

su 根用户登录

export PATH=$PATH:/work/tools/arm/bin

make install

9、cd /usr/local/sqlite3

10、cp -arf bin include lib /work/nfs_root/sqlite/ 复制到nfs共享文件夹下

11、mount -t nfs -o intr,nolock,rsize=1024,wsize=1024 192.168.

0.128:/work/nfs_root /mnt/nfs/ mount nfs文件系统

12、cp /mnt/nfs/sqlite/bin/* /usr/bin/

mkdir /usr/lib

cp -arf /mnt/nfs/sqlite/lib/* /usr/lib/

mkdir /usr/include

cp /mnt/nfs/sqlite/include/* /usr/include/

13、开发板上创建数据库

# /usr/bin/sqlite3 demo

SQLite version 3.6.23.1

Enter ".help" for instructions

Enter SQL statements terminated with a ";"

sqlite> create table tbl_demo(uid int, uname varchar(20));

sqlite> insert into tbl_demo values(1, 'jimmy');

sqlite> insert into tbl_demo values(2, 'srp');

sqlite> .quit

14、编写测试程序test.c

#include

#include

#include "sqlite3.h"

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

{

int i;

for(i=0; i

printf("%s = %s

", azColName[i], argv[i] ? argv[i] : "NULL");

}

printf("

");

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

", argv[0]);

exit(1);

}

rc = sqlite3_open(argv[1], &db);

if( rc ){

fprintf(stderr, "Can't open database: %s

", 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

", zErrMsg);

sqlite3_free(zErrMsg);

}

sqlite3_close(db);

return 0;

} 15、编译 arm-linux-gcc test.c -I /usr/local/sqlite3/include -L /usr/local/sqlite3/lib -lsqlite3 -o test 16、将test拷贝到开发板与数据库demo同一个目录下 sqlite demo test 17、运行 # ./test demo "select * from tbl_demo" uid = 1 uname = jimmy uid = 2 uname = srp 18、sqlite移植成功 注意: #gcc test.c -I /usr/local/sqlite3/include -L /usr/local/sqlite3/lib -lsqlite3 -o test /usr/bin/ld: skipping incompatible /usr/local/sqlite3/lib/libsqlite3.so when searching for -lsqlite3 /usr/bin/ld: skipping incompatible /usr/local/sqlite3/lib/libsqlite3.a when searching for -lsqlite3 /usr/bin/ld: cannot find -lsqlite3 collect2: ld 返回 1 原因:sqlite是使用arm-linux-gcc编译的,所以使用的gcc与arm-linux-gcc不兼容

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/知新_RL/article/detail/173306
推荐阅读
相关标签
  

闽ICP备14008679号