How to statically link SQLite in Delphi

Source: Internet
Author: User
Tags sqlite db

It took me a couple of hours to finally succeed in Delphi. Statically linked

SQLite (v3.5.4), the next step is to study the encryption, hehe
In fact, encountered a lot of problems, today tired, don't say, another day to fill up


Download Test Engineering

Here's how it's said.

1. Download SQLite of courseThe source code, OH, but remember if all in one'sAmalgamationVersion OH
Amended AmalgamationNot all in one, just core code all in one,The other files in the source code are also not few!)
2. Unzip to get 3 files sqlite3.c sqlite3.h sqlite3ext.h
Then compile the sqlite3.c into obj for use in Delphi.
Note that do not use VC compile, to use Borland C + + compiler, such as the Delphi comes with the BCC
This is mainly because the VC compiled obj is in COFF format, while the Borland obj is the OMF format
BCC-compiled command line:bcc32-pc-rt--o-w- -6-i (BCC32) \include-c sqlite3.c
3. Light has sqlite3.obj is not enough oh, hehe, because sqlite3.c have links to other libraries
All the obj files to use are provided hereDownload
4. Now all of the obj files are ready, but don't be too early, just a small part of it ...
To use the functions in these obj in Delphi, you must first declare
First create a new Unit, such as Sqlite3.pas, and then specify the linked obj file, as
{$L ' obj\sqlite3_5_4.obj '}
{$L ' obj\streams.obj '}//duplicato
{$L ' obj\_ftoul.obj '}
{$L ' obj\files.obj '}
Attention Order Oh, hehe
Then add the function declaration
For example, to use the Sqlite3_open method, in the source code of SQLite declares that this is
& nbsp sqlite_api int sqlite3_open (
      const char * filename,  /* Database filename (UTF-8) */
      sqlite3 **ppdb          /* Out:sqlite DB handle */
   );
  The corresponding declaration in Delphi is:
    function _sqlite3_open (Dbname:pchar; var db:pointer): Integer; Cdecl External
  Note The call method is Cdecl, the function name to begin with _, otherwise you will not find
  just sqlite3 function a lot of oh, hehe, so I said only finished part of the work ...
5.OK, complete function declaration is complete
  can now be used formally ~

Problems:
1. Compile times unsatisfied forward or external declaration
This error occurs because the declared function cannot be found
This is generally because the linked obj file is incomplete, or the order is incorrect
There is the declaration of the function name is wrong, cannot find
2. Compile Times Internal error:l3576
Declared function arguments do not match

How to statically link SQLite in Delphi

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.