Compiling the latest SQLite 3.8.4.3 for a DLL

Source: Internet
Author: User

SQLite is a small database, especially suitable for the use of client applications, its many benefits are not much to say, interested in going to search.

Let's say use it.

We want to use it, we need to call it, now step by step.

The first step: on the SQLite website http://www.sqlite.org/download Its source code, its source code has two formats, one is a lot of files are put together, I call the integration code package, the other is a lot. C and. h files, which are separate, I call loose code packages. Loose code package on the requirements of the compilation is relatively high, I do not have the time to study its source code, and then become lazy, using the integrated code package, such as:


Download the code labeled on the diagram

The second step: prepare to compile, download down is a zip, untie, there are shell.c, sqlite3.c, sqlite3.h and sqlite3ext.h so several files, which shell.c we do not need, the others are to use

Step three: Start compiling, take VS2010 as an example, open VS2010, create a Win32 DLL empty project, and then sqlite3.c, Sqlite3.h and sqlite3ext.h These three files to add to the project, to compile a DLL, now it can be compiled, the problem is not exported after compiling the function, is not available, so need a def file (symbol definition file), this file is supposed to be added by ourselves, but if you Do not read the source code is not add, we simple, using the official provided, this to download, of course, or just download location, find SQLite official for us to provide a good DLL download link, to download, such as:


Download down after the zip, there is a def file, copied to the project directory, and then added in the VS2010, now has the export function, but the compilation does not pass, we need to define two macros, they are:

Sqlite_enable_column_metadata

Sqlite_enable_rtree

Add these two macros to the project, such as:


Now compile, you can go through the

Issue one: When you compile the debug version and release version of the two macros to be added separately, otherwise it will not work.

Issue two: Compile release version of the time to remember to set to static compilation, or in the absence of the VC library on the machine can not call this DLL normally.

Fourth step: Optimize processing and invocation

Now that you have a SQLite DLL, for personalization, or other requirements, you can add a version resource, and then write some personalized information, so far, your SQLite DLL has been compiled. I am under VS2010, compiled only 601KB, more than the official 630KB small (DLL is the smaller the better AH), even you can give it a digital signature to highlight the copyright (the official will not limit you to do so).

The fifth step: Results show:


Last question: see a lot of people on the net to solve this DLL interface char and wchar_t problem, I also checked some information, looked under, the official out of these interfaces look is char, in fact is utf-8, that is, what character can handle, but this is for foreign English Department of the country, Domestic users before the string is written to the database, to be converted, read out to be converted again, otherwise it is garbled (seemingly and parse XML like AH).

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.