大佬教程收集整理的这篇文章主要介绍了Sqlite3.78移植到VxWorks6.6,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
A、第一封信
发件人:liuxuezong<liuxuezong@126.com>;
时 间:2011年09月28日 10:27 (星期三)
收件人:drh@hwaci.com
Dear D. Richard Hipp,
Hello,I recently transplanted sqlIE3 to vxworks6.6,encountered some problems,please Help me,thank you! Means there is no problem with memory,the following is vxworks6.6 deBUGging error message:
1,sqlite3.3.7,deBUGging error: database is locked;
2,sqlite3.7.8,deBUGging error: disk i / o error.
liuxuezong shanghai,china.
2011.09.28
B、第二封信
发件人:liuxuezong<liuxuezong@126.com>;
时 间:2011年09月28日 16:05 (星期三)
收件人:drh@hwaci.com
Dear D. Richard Hipp,
Hello,After deBUGging,I found the file control error s =- 1,leading to the above problem: database is locked!
...
lock.l_len = 1L;
lock.l_whence = SEEK_SET;
/* A PENDING lock is needed before acquiring a SHARED lock and before
** acquiring an EXCLUSIVE lock. For the SHARED lock,the PENDING will
** be released.
*/
if( locktype==SHARED_LOCK
|| (locktype==EXCLUSIVE_LOCK && pfile->locktype<PENDING_LOCK)
){
lock.l_type = (locktype==SHARED_LOCK?F_RDLCK:F_WRLCK);
lock.l_start = PENDING_BYTE;
s = fcntl(pfile->h,F_SETLK,&lock);
if( s ){
rc = (errno==EINVAL) ? @R_42_5607@NolFS : @R_42_5607@BUSY;
goto end_lock;
}
}
...
liuxuezong
shanghai,china.
2011.09.28
C、Richard Hipp的回信
发件人:Richard Hipp<drh@sqlite.org>;(由 drhsqlite@gmail.com 代发)
时 间:2011年09月28日 17:57 (星期三)
收件人:liuxuezong <liuxuezong@126.com>;
Please send your requests to the sqlite mailing List. sqlite-users@sqlite.org. See http://www.sqlite.org/support.HTML for additional information.
2011/9/27 liuxuezong <liuxuezong@126.com>
- 显示引用文字 -
--
D. Richard Hipp
1、准备工作
首先从网上下载一个sqlite Developer 3.8.5管理工具,SharpPlus sqlite Developer,强大的sqlite3数据库管理程序,具有如下功能:
☆、强大的sql编辑器
☆、sql编辑历史
☆、sql关键字自动完成
☆、括号高亮匹配
☆、表,字段名自动完成
☆、自动sql语法错误提示
☆、支持Unicode
☆、sql代码格式化器
☆、支持ANSI,UTF8和UTF16数据编辑.
☆、可定制的数据类型映射.
☆、可执行分号分割的多条sql语句.
☆、sql执行监视器.
☆、可视化查询设计器.
☆、可视化表,视图,触发器和索引编辑.
☆、可按文本,16进制,HTML或者位图形式编辑数据.
☆、支持查看和编辑临时表,视图和触发器.
☆、支持查询计划.
☆、自动更新.
☆、可以将数据导出为sql,csv,excel,word,HTML,xml.
☆、可以导入csv文件.
☆、可以导出数据库的元数据.
☆、支持数据库元数据查找
☆、可以中断长时间查询
☆、支持sqlite可加载扩展及虚拟表
☆、多语言支持(英语,简体中文,日语)
其次从sqlite官方网上http://www.sqlite.org/download.html下载一个sqlite3.85开源代码,怎么下载应该比较简单了!
打开sqlite Developer程序,上面的Sample.db将是我们测试的数据源,我们将利用该数据库的部门表见下图“DEPARTMENT”进行验证是否正确,安装之后把Sample.db文件拷贝至$(FEPHOME)/db/目录下,在$(FEPHOME)/code/目录新建文件夹sqlite378,把下载的sqlite3.78包中的sqlite3.h和sqlite3ext.h拷贝此处。
2、测试代码
// testsqlite378.cpp : defines the entry point for the console application. // #include "stdafx.h" #include <stdio.h> #include <stdlib.h> #include <String.h> #include "sqlite378/sqlite3.h" // $(FEPHOME)/code/inlcude/sqlite378 int main(int argc,char* argv[]) { sqlite3 *db = NulL; char *zErrMsg = 0; int rc; char *szWorkPath = "/e/openSUSE3000/fep/db/Sample.db3"; rc = sqlite3_open(szWorkPath,@R_482_4616@; // 打开指定的数据库文件. if (rC) { fprintf(stderr,"Can't open database: %s\n",sqlite3_errmsg(db)); sqlite3_close(db); return (1); } else { printf("You have opened a sqlite3 database named Sample.db3 successfully!\n"); } int nrow = 0,ncolumn = 0; char **azResult; // 二维数组存放结果 // 查询数据 char *sql = "SELECT * FROM DEPARTMENT"; sqlite3_get_table(db,sql,&azResult,&nrow,&ncolumn,&zErrMsg); int i = 0 ; printf("row:%d column=%d \n",nrow,ncolumn); printf("\nThe result of querying is : \n"); for (i = 0 ; i < ( nrow + 1 ) * ncolumn ; i++) printf("azresult[%d] = %s\n",i,azresult[i]); // 释放掉 azResult 的内存空间 sqlite3_free_table(azResult); #ifdef _DEBUG_ printf("zErrMsg = %s \n",zErrMsg); #endif sqlite3_close(db); // 关闭数据库 return 0; }
3、生成库代码libsqlite378
在生成库时需要一些配置,具体内容如下:
defines:-DOS_VXWORKS=1 -D_HAVE_@R_42_5607@CONfig_H -D@R_42_5607@THREADSAFE=0
OS_VXWORKS:说明使用操作系统VxWorks.
_HAVE_@R_42_5607@CONfig_H:将使用配置文件“config.h”
#ifndef _CONfig_H_ #define _CONfig_H_ #define @R_42_5607@OMIT_LOAD_EXTENSION 1 // 不需要动态库支持 #define HAVE_UTIME // 使用utime函数而不是utimes函数 #include <semaphore.h> /* * 不使用VxWorks提供的POSIX标准中的互斥信号量递归接口,因为对于内核程序,POSIX支持* 的不是太好 */ #define @R_42_5607@HOMEGROWN_REcursIVE_MUTEX 1 #include <vxWorks.h> #endif // _CONfig_H_
@R_42_5607@THREADSAFE=<0 or 1 or 2>
This option controls whether or not code is included in sqlite to enable it to operate safely in a multithreaded environment. The default is @R_42_5607@THREADSAFE=1 which is safe for use in a multithreaded environment. When compiled with @R_42_5607@THREADSAFE=0 all mutexing code is omitted and it is unsafe to use sqlite in a multithreaded program. When compiled with @R_42_5607@THREADSAFE=2,sqlite can be used in a multithreaded program so long as no two threads attempt to use the same database connection at the same time.
To put it another way,@R_42_5607@THREADSAFE=1 sets the default threading mode to serialized. @R_42_5607@THREADSAFE=2 sets the default threading mode to Multi-threaded. And @R_42_5607@THREADSAFE=0 sets the threading mode to Single-threaded.
The value of @R_42_5607@THREADSAFE can be determined at run-time using the sqlite3_threadsafe() interface.
When sqlite has been compiled with @R_42_5607@THREADSAFE=1 or @R_42_5607@THREADSAFE=2 then the threading mode can be altered at run-time using the sqlite3_config() interface together with one of these verbs:
The @R_42_5607@OPEN_NOMUTEX and @R_42_5607@OPEN_FULLMUTEX flags to sqlite3_open_v2() can also be used to adjust the threading mode of indivIDual database connections at run-time.
Note that when sqlite is compiled with @R_42_5607@THREADSAFE=0,the code to make sqlite threadsafe is omitted from the build. When this occurs,it is impossible to change the threading mode at start-time or run-time.
See the threading mode documentation for additional information on aspects of using sqlite in a multithreaded environment.
3、调试代码testsqlite378
testsqlite378生成比较简单,具体可以看前面关于嵌入系统调试的内容了。
4、Console输出的内容:
You have opened a sqlite3 database named Sample.db3 successfully!
row:21 column=7
The result of querying is :
azresult[0] = DEPT_NO
azresult[1] = DEPARTMENT
azresult[2] = head_DEPT
azresult[4] = BUDGET
azresult[7] = 000
azresult[8] = Corporate headquarters
azresult[9] =
azresult[10] = 105
azresult[11] = 1000000
azresult[12] = Monterey
azresult[13] = (408) 555-1234
azresult[14] = 100
azresult[15] = SALEs and MarkeTing
azresult[17] = 85
azresult[19] = San Francisco
azresult[20] = (415) 555-1234
azresult[21] = 600
azresult[23] = 000
azresult[24] = 2
azresult[27] = (408) 555-1234
azresult[28] = 900
azresult[29] = Finance
azresult[31] = 46
azresult[33] = Monterey
azresult[34] = (408) 555-1234
azresult[37] = 100
azresult[38] =
azresult[39] = 1500000
azresult[40] = San Francisco
azresult[41] = (415) 555-1234
azresult[42] = 620
azresult[43] = Software Products div.
azresult[44] = 600
azresult[47] = Monterey
azresult[48] = (408) 555-1234
azresult[49] = 621
azresult[50] = Software Development
azresult[51] = 620
azresult[52] =
azresult[53] = 400000
azresult[54] = Monterey
azresult[57] = Quality Assurance
azresult[58] = 620
azresult[59] = 9
azresult[60] = 300000
azresult[61] = Monterey
azresult[62] = (408) 555-1234
azresult[63] = 623
azresult[64] = Customer Support
azresult[67] = 650000
azresult[68] = Monterey
azresult[69] = (408) 555-1234
azresult[70] = 670
azresult[71] = Consumer Electronics div.
azresult[72] = 600
azresult[73] = 107
azresult[74] = 1150000
azresult[77] = 671
azresult[78] = Research and Development
azresult[79] = 670
azresult[80] = 20
azresult[81] = 460000
azresult[82] = Burlington VT
azresult[83] = (802) 555-1234
azresult[84] = 672
azresult[85] = Customer services
azresult[87] = 94
azresult[88] = 850000
azresult[89] = Burlington VT
azresult[90] = (802) 555-1234
azresult[91] = 130
azresult[92] = FIEld Office: East Coast
azresult[93] = 100
azresult[94] = 11
azresult[97] = (617) 555-1234
azresult[98] = 140
azresult[99] = FIEld Office: Canada
azresult[100] = 100
azresult[101] = 72
azresult[102] = 500000
azresult[103] = Toronto
azresult[104] = (416) 677-1000
azresult[106] = Pacific Rim headquarters
azresult[107] = 100
azresult[108] = 34
azresult[109] = 600000
azresult[110] = Kuaui
azresult[111] = (808) 555-1234
azresult[112] = 115
azresult[113] = FIEld Office: Japan
azresult[114] = 110
azresult[117] = Tokyo
azresult[118] = 3 5350 0901
azresult[119] = 116
azresult[120] = FIEld Office: Singapore
azresult[121] = 110
azresult[122] =
azresult[123] = 300000
azresult[124] = Singapore
azresult[127] = European headquarters
azresult[128] = 100
azresult[129] = 36
azresult[131] = London
azresult[133] = 121
azresult[134] = FIEld Office: Switzerland
azresult[137] = 500000
azresult[138] = Zurich
azresult[139] = 1 211 7767
azresult[140] = 123
azresult[141] = FIEld Office: France
azresult[142] = 120
azresult[143] = 134
azresult[144] = 400000
azresult[147] = 125
azresult[148] = FIEld Office: Italy
azresult[149] = 120
azresult[151] = 400000
azresult[152] = Milan
azresult[153] = 2 430 39 39
从控制输出的内容,我们可以看出的结果与表格显示一致,那说明我们的移植成功了
以上是大佬教程为你收集整理的Sqlite3.78移植到VxWorks6.6全部内容,希望文章能够帮你解决Sqlite3.78移植到VxWorks6.6所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。