http://19831028.blog.51cto.com/1333653/301419
http://blog.csdn.net/androidbluetooth/article/details/6573588
安裝好了,但是沒有編譯出庫檔案 ,好像不能開發應用程式調用API
sqlite3 資料庫命令操作 sqlite3資料庫與mysql資料庫的匯入匯出http://www.cnblogs.com/wdpp/archive/2011/11/30/2386714.html
執行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’
你的Hello World兩邊的引號怎麼用了中文的引號呢?
我給你帖一個,你仔細比較一下引號。
#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’ 不相容”和一些標頭檔