- 论坛徽章:
- 0
|
我已经交叉编译了一个可以在ARM上运行的数据库sqlite,放在挂载在开发板上的目录下,已经在开发板上可以运行(命令行运行过),现在我写了个本地访问的程序,如下:
#include <stdio.h>
#include <string.h>
#include "sqlite.h"
#define SQLITE_OK 0
/*typedef struct sqlite sqlite;*/
int callback(void *datarow,int num_fields,char * * p_fields,char * * p_col_names)
{int i;
int *p_rn=(int *)datarow;
/* (p_rn)++;*/
for(i=0;i<num_fields;i++)
{printf("%s|",p_fields);
}
return 0;
}
main()
{ int revalue;
sqlite * db;
FILE * file;
int row=0;
char * * erromsg;
char * sqlselect="select * from tbll;";
char * sqlcreate="create table tbll(name varchar(10),two smallint(20));";
if ((file=fopen("./testdbs","r+" )==NULL)
{ printf("Cannot open database file!\n" ;
printf("Create the database file ...\n" ;
db=sqlite_open("./testdbs",0777,0);
sqlite_exec(db,sqlcreate,0,0,0);
printf("The database file have been create!\n" ;
sqlite_close(db);
}
db=sqlite_open("./testdbs",0777,0);
revalue=sqlite_exec(db,sqlselect,callback,&row,erromsg);
if(revalue!=SQLITE_OK)
{printf("View database testdbs failed!\n" ;
}
else
{printf("Success!" ;
}
sqlite_close(db);
fclose(file);
}
但是,在用arm-linux-gcc编译它时通不过,这是怎么回事??
[root@localhost arm_linux_sqlite]# ls
attach.lo build.lo date.o func.o libtool opcodes.o parse.o random.o sqlitetest.o trigger.o vdbeaux.o
attach.o build.o delete.lo hash.lo main.lo os.lo parse.out select.lo table.lo update.lo vdbe.lo
auth.lo config.h delete.o hash.o main.o os.o parse.y select.o table.o update.o vdbe.o
auth.o config.log encode.lo insert.lo Makefile pager.lo pragma.lo sqlite testdb util.lo where.lo
btree.lo config.status encode.o insert.o Makefilesqlite pager.o pragma.o sqlite.h testdbs util.o where.o
btree.o copy.lo expr.lo lemon opcodes.c parse.c printf.lo sqlite.pc tokenize.lo vacuum.lo
btree_rb.lo copy.o expr.o lempar.c opcodes.h parse.h printf.o sqlitetest.c tokenize.o vacuum.o
btree_rb.o date.lo func.lo libsqlite.la opcodes.lo parse.lo random.lo sqlitetestfile trigger.lo vdbeaux.lo
[root@localhost arm_linux_sqlite]# arm-linux-gcc -o sqlitetest sqlitetest.o
sqlitetest.o: In function `main':
sqlitetest.o(.text+0xec): undefined reference to `sqlite_open'
sqlitetest.o(.text+0x110): undefined reference to `sqlite_exec'
sqlitetest.o(.text+0x120): undefined reference to `sqlite_close'
sqlitetest.o(.text+0x134): undefined reference to `sqlite_open'
sqlitetest.o(.text+0x15 : undefined reference to `sqlite_exec'
sqlitetest.o(.text+0x1ac): undefined reference to `sqlite_close'
collect2: ld returned 1 exit status
[root@localhost arm_linux_sqlite]#
清高手指点.sqlitetest.c |
|