http://19831028.blog.51cto.com/1333653/301419
http://blog.youkuaiyun.com/androidbluetooth/article/details/6573588
安装好了,但是没有编译出库文件 ,好像不能开发应用程序调用API
sqlite3 数据库命令操作
sqlite3数据库与mysql数据库的导入导出
执行sqlite3_exec查询整个数据库的时候,回调函数怎么能 返回全部的查询结果,
struct olt_info
{
int olt_index;
int olt_logo;
char* olt_line;
// int nmber;
};
int my_callback(void *olt_temp, int argc, char *value[], char *name[])
{
struct olt_info *pdata = NULL;
pdata = (struct olt_info *)olt_temp;
int jj;
for (int i = 0; i < argc; i++)
jj = printf("%s == %s\n", name[i], value[i]);
pdata->olt_index = (int)atoi(value[0]);
pdata->olt_logo = (int)atoi(value[1]);
pdata->olt_line = value[2];
return 0;
}
这样可以打印,但是 不能返回。 这样做的话只能返回最后一个。无法全部返回。。请问怎么才能全部返回??
这个回调函数在每得到一行结果的时候就会执行一次,所以pdata的的内容一直在变化。而你只能得到最后一行的结果。
试试用链表或队列来保存? [/quote]
cp -rf /mnt/hgfs/share /home 复制文件到目录下
http://tech.ddvip.com/2007-10/119338075236567.html
Sqlite数据库转Mysql程序http://www.sqlite.com.cn/MySqlite/6/377.Html
问题1:
经过半天的努力,终于在vim下敲打出了第一个C程序,可是使用编译命令后, gcc hello.c,出现如下结果,我不知道是哪的错,请高手指点。
-----------------------------------------------------------------------------------------------------------
-bash-3.1$ gcc hello.c
hello.c: 在函数 ‘main’ 中:
hello.c:5: 错误:程序中有游离的 ‘\241’
hello.c:5: 错误:程序中有游离的 ‘\261’
hello.c:5: 错误:‘Hello’ 未声明 (在此函数内第一次使用)
hello.c:5: 错误:(即使在一个函数内多次出现,每个未声明的标识符在其
hello.c:5: 错误:所在的函数内只报告一次。)
hello.c:5: 错误:expected ‘)’ before ‘World’
hello.c:5: 错误:程序中有游离的 ‘\’
hello.c:5: 错误:程序中有游离的 ‘\241’
hello.c:5: 错误:程序中有游离的 ‘\261’
我给你帖一个,你仔细比较一下引号。
#include <stdio.h>
int main()
{
printf("Hello World!\n");
return 0;
}
问题2:undefined reference to `sqlite3_open'
假设你已经正确编译和安装了Sqlite,写个测试程序来测试:
#include <stdlib.h>
#include <stdio.h>
#include "sqlite3.h"
int main(void)
{
sqlite3 *db=NULL;
char *zErrMsg = 0;
int rc;
rc=sqlite3_open("test1.db",&db);
if(rc)
{
fprintf(stderr,"Can't open database: %s\n",sqlite3_errmsg(db));
sqlite3_close(db);
exit(1);
}
else printf("open mydata successfully!\n");
sqlite3_close(db);
return 0;
}
用GCC来编译的时候总是会出现错误,编译的命令如下
gcc -static -o hello -lsqlite3 -L /usr/local/lib -I/usr/local/include hello.c
错误信息如下
/tmp/ccKeKpX9.o(.text+0x37): In function `main':
: undefined reference to `sqlite3_open'
/tmp/ccKeKpX9.o(.text+0x51): In function `main':
: undefined reference to `sqlite3_errmsg'
/tmp/ccKeKpX9.o(.text+0x73): In function `main':
: undefined reference to `sqlite3_close'
/tmp/ccKeKpX9.o(.text+0x9b): In function `main':
: undefined reference to `sqlite3_close'
collect2: ld returned 1 exit status
那么,恭喜你中招了。错误根本不在SQLITE也不在你的程序,而在GCC。Gcc的编译参数是有顺序的。正确的编译命令是:
gcc -o hello -L /usr/local/lib -I/usr/local/include -static hello.c -lsqlite3
确认make install正确无误后,运行
ldconfig (man ldconfig, see FILES section。或者先将/usr/local/lib加入/etc/ld.so.conf。看情况你的sqlite是被安装/usr/local下)
然后
ldconfig -p | grep libsqlite
确认。
编译程序时
gcc -o executible -L/usr/local/lib -lsqlite src.c
建议info gcc/ld/Makefile
这是因为gcc找不到定义sqlite3_open等等的头文件,经过在网上查找资料,
找到了解决方法,使用如下的方法进行编译:
$ gcc -o hello -L /usr/local/sqlite-autoconf-3070400/lib -I/usr/local/sqlite-autoconf-307040/include sqlitetest.c -lsqlite3
上面的编译主要意义时-L 代码你安装sqlite3类库所在的路径, -I代表安装sqlite3的头文件路径 而-l表示
可执行程序的名称
经过上面的编译,即可成功。
执行结果如下:
~$ ./hello
数据库连接成功!
插入数据成功
插入数据成功
查询数据库内容
userid = 张三
age = 20
birthday = 2011-7-23
userid = 李四
age = 20
birthday = 2012-9-20
数据库关闭成功!
http://blog.sina.com.cn/s/blog_7516537d0100tedt.html 警告:隐式声明与内建函数 ‘memcpy’ 不兼容”和一些头文件