delphi+sqlite3如何静态连接呢。在网上看了一些,别人也传给我了一堆OBJ文件,
可是编译的时候报一堆错,听说好像跟什么顺序有关。
谁教教我啊。
可是编译的时候报一堆错,听说好像跟什么顺序有关。
谁教教我啊。
解决方案 »
- 咨询下大家在北京的生活开销
- 关于事件响应问题!!!!!超级急!
- StringGrid填充问题
- 问一个弱者的问题,但我确实不会,如何用ADOQuery把一条记录添加到数据库尾部!
- QuickReport中如何画表格线?
- 這個Adoquery的錯誤如何解決
- DELPHI7 里面TCPCLIENT/TCPSERVER控件的使用问题?
- 我给100分!!!谁有邮件内容解码函数MimeDecodeString吗!
- 300分急寻:Magic CD Burner,CDWriterXP,NuCDR三个控件刻出来的光盘文件名都是乱码,有谁知道怎样解决,或更好的控件可以做光盘刻录程序?
- api?
- 大家好,有些基础的程序效率和算法相关的问题想问一下。
- 请教delphi问题(动态创建TMemo 后,如何按名称引用)
unit SQLite3;{
Simplified interface for SQLite.
Updated for Sqlite 3 by Tim Anderson ([email protected])
Update for use with Dbx4Pg by Thiago Borges de Oliveira (thborges at gmail.com)
Note: NOT COMPLETE for version 3, just minimal functionality
Adapted from file created by Pablo Pissanetzky ([email protected])
which was based on SQLite.pas by Ben Hochstrasser ([email protected])
}interfaceconst // SQLiteDLL = 'sqlite3.dll'; // Return values for sqlite3_exec() and sqlite3_step() __turboFloat: integer = 0; SQLITE_OK = 0; // Successful result
SQLITE_ERROR = 1; // SQL error or missing database
SQLITE_INTERNAL = 2; // An internal logic error in SQLite
SQLITE_PERM = 3; // Access permission denied
SQLITE_ABORT = 4; // Callback routine requested an abort
SQLITE_BUSY = 5; // The database file is locked
SQLITE_LOCKED = 6; // A table in the database is locked
SQLITE_NOMEM = 7; // A malloc() failed
SQLITE_READONLY = 8; // Attempt to write a readonly database
SQLITE_INTERRUPT = 9; // Operation terminated by sqlite3_interrupt()
SQLITE_IOERR = 10; // Some kind of disk I/O error occurred
SQLITE_CORRUPT = 11; // The database disk image is malformed
SQLITE_NOTFOUND = 12; // (Internal Only) Table or record not found
SQLITE_FULL = 13; // Insertion failed because database is full
SQLITE_CANTOPEN = 14; // Unable to open the database file
SQLITE_PROTOCOL = 15; // Database lock protocol error
SQLITE_EMPTY = 16; // Database is empty
SQLITE_SCHEMA = 17; // The database schema changed
SQLITE_TOOBIG = 18; // Too much data for one row of a table
SQLITE_CONSTRAINT = 19; // Abort due to contraint violation
SQLITE_MISMATCH = 20; // Data type mismatch
SQLITE_MISUSE = 21; // Library used incorrectly
SQLITE_NOLFS = 22; // Uses OS features not supported on host
SQLITE_AUTH = 23; // Authorization denied
SQLITE_FORMAT = 24; // Auxiliary database format error
SQLITE_RANGE = 25; // 2nd parameter to sqlite3_bind out of range
SQLITE_NOTADB = 26; // File opened that is not a database file
SQLITE_ROW = 100; // sqlite3_step() has another row ready
SQLITE_DONE = 101; // sqlite3_step() has finished executing SQLITE_INTEGER = 1;
SQLITE_FLOAT = 2;
SQLITE_TEXT = 3;
SQLITE_BLOB = 4;
SQLITE_NULL = 5; SQLITE_UTF8 = 1;
SQLITE_UTF16 = 2;
SQLITE_UTF16BE = 3;
SQLITE_UTF16LE = 4;
SQLITE_ANY = 5; SQLITE_TRANSIENT = pointer(-1);
SQLITE_STATIC = pointer(0);type
TSQLiteDB = pointer;
TSQLiteResult = ^PAnsiChar;
TSQLiteStmt = pointer; // function prototype for define own collate
TCollateXCompare = function(Userdta: pointer; Buf1Len: integer;
Buf1: pointer; Buf2Len: integer; Buf2: pointer): integer; cdecl;function _SQLite3_Open(dbname: PAnsiChar; var db: TSQLiteDB): integer; cdecl;
external;
function _SQLite3_Close(db: TSQLiteDB): integer; cdecl; external;
function _SQLite3_Exec(db: TSQLiteDB; SQLStatement: PAnsiChar;
CallbackPtr: pointer; Sender: TObject; var ErrMsg: PAnsiChar): integer;
cdecl; external;
function _SQLite3_Version(): PAnsiChar; cdecl; external;
function _SQLite3_ErrMsg(db: TSQLiteDB): PAnsiChar; cdecl; external;
function _SQLite3_ErrCode(db: TSQLiteDB): integer; cdecl; external;
procedure _SQlite3_Free(P: PAnsiChar); cdecl; external;
function _SQLite3_Get_Table(db: TSQLiteDB; SQLStatement: PAnsiChar;
var ResultPtr: TSQLiteResult; var RowCount: Cardinal;
var ColCount: Cardinal; var ErrMsg: PAnsiChar): integer; cdecl; external;
procedure _SQLite3_Free_Table(Table: TSQLiteResult); cdecl; external;
function _SQLite3_Complete(P: PAnsiChar): boolean; cdecl; external;
function _SQLite3_Last_Insert_RowID(db: TSQLiteDB): Int64; cdecl; external;
procedure _SQLite3_Interrupt(db: TSQLiteDB); cdecl; external;
procedure _SQLite3_Busy_Handler(db: TSQLiteDB; CallbackPtr: pointer;
Sender: TObject); cdecl; external;
procedure _SQLite3_Busy_Timeout(db: TSQLiteDB; TimeOut: integer); cdecl;
external;
function _SQLite3_Changes(db: TSQLiteDB): integer; cdecl; external;
function _SQLite3_Total_Changes(db: TSQLiteDB): integer; cdecl; external;
function _SQLite3_Prepare(db: TSQLiteDB; SQLStatement: PAnsiChar;
nBytes: integer; var hStmt: TSQLiteStmt; var pzTail: PAnsiChar): integer;
cdecl; external;
function _SQLite3_Prepare_v2(db: TSQLiteDB; SQLStatement: PAnsiChar;
nBytes: integer; var hStmt: TSQLiteStmt; var pzTail: PAnsiChar): integer;
cdecl; external;
function _SQLite3_Column_Count(hStmt: TSQLiteStmt): integer; cdecl; external;
function _Sqlite3_Column_Name(hStmt: TSQLiteStmt; ColNum: integer): PAnsiChar;
cdecl; external;
function _Sqlite3_Column_DeclType(hStmt: TSQLiteStmt;
ColNum: integer): PAnsiChar; cdecl; external;
function _Sqlite3_Step(hStmt: TSQLiteStmt): integer; cdecl; external;
function _SQLite3_Data_Count(hStmt: TSQLiteStmt): integer; cdecl; external;// function _Sqlite3_Column_TableName(hStmt: TSqliteStmt; ColNum: integer): PAnsiChar; cdecl; external;function _Sqlite3_Column_Blob(hStmt: TSQLiteStmt; ColNum: integer): pointer;
cdecl; external;
function _Sqlite3_Column_Bytes(hStmt: TSQLiteStmt; ColNum: integer): integer;
cdecl; external;
function _Sqlite3_Column_Double(hStmt: TSQLiteStmt; ColNum: integer): double;
cdecl; external;
function _Sqlite3_Column_Int(hStmt: TSQLiteStmt; ColNum: integer): integer;
cdecl; external;
function _Sqlite3_Column_Text(hStmt: TSQLiteStmt; ColNum: integer): PAnsiChar;
cdecl; external;
function _Sqlite3_Column_Type(hStmt: TSQLiteStmt; ColNum: integer): integer;
cdecl; external;
function _Sqlite3_Column_Int64(hStmt: TSQLiteStmt; ColNum: integer): Int64;
cdecl; external;
function _SQLite3_Finalize(hStmt: TSQLiteStmt): integer; cdecl; external;
function _SQLite3_Reset(hStmt: TSQLiteStmt): integer; cdecl; external;
function _SQLite3_Clear_Bindings(hStmt: TSQLiteStmt): integer; cdecl; external;//
// In the SQL strings input to sqlite3_prepare() and sqlite3_prepare16(),
// one or more literals can be replace by a wildcard "?" or ":N:" where
// N is an integer. These value of these wildcard literals can be set
// using the routines listed below.
//
// In every case, the first parameter is a pointer to the sqlite3_stmt
// structure returned from sqlite3_prepare(). The second parameter is the
// index of the wildcard. The first "?" has an index of 1. ":N:" wildcards
// use the index N.
//
// The fifth parameter to sqlite3_bind_blob(), sqlite3_bind_text(), and
// sqlite3_bind_text16() is a destructor used to dispose of the BLOB or
// text after SQLite has finished with it. If the fifth argument is the
// special value SQLITE_STATIC, then the library assumes that the information
// is in static, unmanaged space and does not need to be freed. If the
// fifth argument has the value SQLITE_TRANSIENT, then SQLite makes its
// own private copy of the data.
//
// The sqlite3_bind_* routine must be called before sqlite3_step() after
// an sqlite3_prepare() or sqlite3_reset(). Unbound wildcards are interpreted
// as NULL.
//function _SQLite3_Bind_Blob(hStmt: TSQLiteStmt; ParamNum: integer;
ptrData: pointer; numBytes: integer; ptrDestructor: pointer): integer;
cdecl; external;
function _SQLite3_Bind_Double(hStmt: TSQLiteStmt; ParamNum: integer;
Data: double): integer; cdecl; external;
function _SQLite3_Bind_Int(hStmt: TSQLiteStmt; ParamNum: integer;
intData: integer): integer; cdecl; external;
function _SQLite3_Bind_int64(hStmt: TSQLiteStmt; ParamNum: integer;
Data: Int64): integer; cdecl; external;
function _SQLite3_Bind_null(hStmt: TSQLiteStmt; ParamNum: integer): integer;
cdecl; external;
function _SQLite3_Bind_text(hStmt: TSQLiteStmt; ParamNum: integer;
Data: PAnsiChar; numBytes: integer; ptrDestructor: pointer): integer; cdecl;
external;function _SQLite3_Bind_Parameter_Index(hStmt: TSQLiteStmt;
zName: PAnsiChar): integer; cdecl; external;function _sqlite3_enable_shared_cache(value: integer): integer; cdecl; external;// user collate definiton
function _sqlite3_create_collation(db: TSQLiteDB; Name: PAnsiChar;
eTextRep: integer; UserData: pointer; xCompare: TCollateXCompare): integer;
cdecl; external;function SQLiteFieldType(SQLiteFieldTypeCode: integer): String;
function SQLiteErrorStr(SQLiteErrorCode: integer): String;function _atol(const s: PAnsiChar): integer; cdecl;
external 'msvcrt.dll' name 'atol';
function __ftol(f: double): integer; cdecl; external 'msvcrt.dll' name '_ftol';
function __ftoul(f: double): longword; cdecl;
external 'msvcrt.dll' name '_ftol';
function _malloc(s: longword): pointer; cdecl;
external 'msvcrt.dll' name 'malloc';
procedure _free(P: pointer); cdecl; external 'msvcrt.dll' name 'free';
function _realloc(P: pointer; s: longword): pointer; cdecl;
external 'msvcrt.dll' name 'realloc';
function _localtime(const __timer: pointer): pointer; cdecl;
external 'msvcrt.dll' name 'localtime';implementationuses
Windows, SysUtils;
{$LINK .\obj\sqlite3.obj}
{$LINK .\obj\_ll.obj}
{$LINK .\obj\strncmp.obj}
{$LINK .\obj\memset.obj}
{$LINK .\obj\memcpy.obj}
{$LINK .\obj\memmove.obj}
{$LINK .\obj\memcmp.obj}
begin
case SQLiteFieldTypeCode of
SQLITE_INTEGER:
Result := 'Integer';
SQLITE_FLOAT:
Result := 'Float';
SQLITE_TEXT:
Result := 'Text';
SQLITE_BLOB:
Result := 'Blob';
SQLITE_NULL:
Result := 'Null';
else
Result := 'Unknown SQLite Field Type Code "' + IntToStr
(SQLiteFieldTypeCode) + '"';
end;
end;function SQLiteErrorStr(SQLiteErrorCode: integer): String;
begin
case SQLiteErrorCode of
SQLITE_OK:
Result := 'Successful result';
SQLITE_ERROR:
Result := 'SQL error or missing database';
SQLITE_INTERNAL:
Result := 'An internal logic error in SQLite';
SQLITE_PERM:
Result := 'Access permission denied';
SQLITE_ABORT:
Result := 'Callback routine requested an abort';
SQLITE_BUSY:
Result := 'The database file is locked';
SQLITE_LOCKED:
Result := 'A table in the database is locked';
SQLITE_NOMEM:
Result := 'A malloc() failed';
SQLITE_READONLY:
Result := 'Attempt to write a readonly database';
SQLITE_INTERRUPT:
Result := 'Operation terminated by sqlite3_interrupt()';
SQLITE_IOERR:
Result := 'Some kind of disk I/O error occurred';
SQLITE_CORRUPT:
Result := 'The database disk image is malformed';
SQLITE_NOTFOUND:
Result := '(Internal Only) Table or record not found';
SQLITE_FULL:
Result := 'Insertion failed because database is full';
SQLITE_CANTOPEN:
Result := 'Unable to open the database file';
SQLITE_PROTOCOL:
Result := 'Database lock protocol error';
SQLITE_EMPTY:
Result := 'Database is empty';
SQLITE_SCHEMA:
Result := 'The database schema changed';
SQLITE_TOOBIG:
Result := 'Too much data for one row of a table';
SQLITE_CONSTRAINT:
Result := 'Abort due to contraint violation';
SQLITE_MISMATCH:
Result := 'Data type mismatch';
SQLITE_MISUSE:
Result := 'Library used incorrectly';
SQLITE_NOLFS:
Result := 'Uses OS features not supported on host';
SQLITE_AUTH:
Result := 'Authorization denied';
SQLITE_FORMAT:
Result := 'Auxiliary database format error';
SQLITE_RANGE:
Result := '2nd parameter to sqlite3_bind out of range';
SQLITE_NOTADB:
Result := 'File opened that is not a database file';
SQLITE_ROW:
Result := 'sqlite3_step() has another row ready';
SQLITE_DONE:
Result := 'sqlite3_step() has finished executing';
else
Result := 'Unknown SQLite Error Code "' + IntToStr(SQLiteErrorCode) + '"';
end;
end;function ColValueToStr(value: PAnsiChar): String;
begin
if (value = nil) then
Result := 'NULL'
else
Result := String(PAnsiChar(value));
end;end.
就是这样的静态链接,没问题啊
你的
{$LINK .\obj\_ll.obj}
{$LINK .\obj\strncmp.obj}
{$LINK .\obj\memset.obj}
{$LINK .\obj\memcpy.obj}
{$LINK .\obj\memmove.obj}
{$LINK .\obj\memcmp.obj}这几个OBJ文件在哪弄的呢。我编译好了sqlite3.obj就是调用时报好多错。
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '__ftol'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '__lldiv'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '__llmod'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '_localtime'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '_memset'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '_strcmp'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '_strncmp'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '__llmul'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '_malloc'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '_free'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '_realloc'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '_memcpy'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'InterlockedCompareExchange'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'InitializeCriticalSection'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'Sleep'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'DeleteCriticalSection'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'EnterCriticalSection'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'LeaveCriticalSection'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '__llumod'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '__lludiv'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '_memmove'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetVersionExA'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'MultiByteToWideChar'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'WideCharToMultiByte'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'AreFileApisANSI'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'FormatMessageW'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'LocalFree'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'FormatMessageA'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'SetFilePointer'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'CloseHandle'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'ReadFile'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'WriteFile'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'SetEndOfFile'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'FlushFileBuffers'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetFileSize'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'LockFileEx'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'LockFile'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'UnlockFile'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'UnlockFileEx'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'UnmapViewOfFile'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'CreateFileMappingA'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'MapViewOfFile'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetTempPathW'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetTempPathA'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'CreateFileW'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'CreateFileA'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'DeleteFileW'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetFileAttributesW'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'DeleteFileA'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetFileAttributesA'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetFileAttributesExW'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetFullPathNameW'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetFullPathNameA'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetDiskFreeSpaceW'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetDiskFreeSpaceA'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'LoadLibraryW'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'LoadLibraryA'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetProcAddress'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'FreeLibrary'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetSystemTime'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetCurrentProcessId'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetTickCount'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'QueryPerformanceCounter'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetSystemTimeAsFileTime'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: 'GetSystemInfo'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '_memcmp'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '__llshl'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '__llushr'
[Error] sqlite.pas(32775): Unsatisfied forward or external declaration: '__turboFloat'
[Fatal Error] Project1.dpr(6): Could not compile used unit 'sqlite.pas'
的确是非常好用,如果能支持存贮过程就好了。
我不喜欢把SQL都编译到执行文件中...
你的obj文件太少了,
我弄的时候有一大堆。
而且顺序不能错,
不然就无法编译通过。
静态编译,obj只能是borland自己的格式,比较流行的vc生成的obj还不能用,也是麻烦
原来是在http://www.aducom.com
http://www.cnblogs.com/xunxun/archive/2011/03/03/1969682.html
已试过,有效!
好像是07年的dll,与最新的dll比,会不会少一下功能或有一些bug?
支持加密的dll,需要特别的pas吧?