First, the SQLite official website already has pre-compiled DLL downloads. If you do not need a specially optimized version, you can directly download the DLL on the official website. On the download page, you can find "precompiled binaries for Windows.
However, You Want To compile your own version, such as compile after adding optimization parameters, debug version, or make some customization (for example, there are some pre-compiled macros on the official website, allow you to customize your own SQLite), then you need to compile your own.
First download the source code, the first line on the page is, such as the sqlite-amalgamation-3_6_12.zip, and then download the compiled DLL, we mainly need a sqlite3.def file here, because the source code does not exist. Generally drop down to "precompiled binaries for Windows" you can see, such as sqlitedll-3_6_12.zip. With these two compressed packages, you can.
First decompress the sqlite-amalgamation-3_6_12.zip to the folder sqlite3/, you will get
Sqlite3.c, sqlite3.h, sqlite3ext. h three files, then extract the sqlitedll-3_6_12.zip
Move sqlite3.def to sqlite3.
Open Visual Studio and create an empty DLL project named sqlite3 to directly generate a DLL named sqlite3.dll. Then four file folders under sqlite3/are moved to the project directory, that is, at the same level as sqlite3.vcproj.
Add sqlite3.c to the project. Right-click "source file", select "Add-> existing items", and browse to sqlite3.c. As shown in.
Then add sqlite3.def to the project and input it to the connector. Right-click the project sqlite3, select "properties", select "connector-> input" in the displayed dialog box, and enter sqlite3.def in the module definition file, as shown in.
Okay, you can start compiling. Right-click sqlite3 and select "generate". The result link is incorrect,
-- Generation started: Project: sqlite3, configuration: Release Win32 --
Compiling...
Sqlite3.c
Linking...
Sqlite3.def: Error lnk2001: the external symbol sqlite3_column_database_name that cannot be parsed
Sqlite3.def: Error lnk2001: external symbol that cannot be parsed sqlite3_column_database_name16
Sqlite3.def: Error lnk2001: the external symbol sqlite3_column_origin_name that cannot be parsed
Sqlite3.def: Error lnk2001: external symbol that cannot be parsed sqlite3_column_origin_name16
Sqlite3.def: Error lnk2001: external symbol that cannot be parsed sqlite3_column_table_name
Sqlite3.def: Error lnk2001: external symbol that cannot be parsed sqlite3_column_table_name16
Sqlite3.def: Error lnk2001: external symbol that cannot be parsed sqlite3_table_column_metadata
It seems that the export functions defined in sqlite3.def cannot be defined. Why? After some Google attempts to find this article, we need to add a predefined macro sqlite_enable_column_metadata. What does this macro mean, go to the official website to check,
Sqlite_enable_column_metadata
When this C-Preprocessor macro is defined, SQLite already des some
Additional APIs that provide convenient access to meta-data about
Tables and queries. The APIs that are enabled by this option are:
* Sqlite3_column_database_name ()
* Sqlite3_column_database_name16 ()
* Sqlite3_column_table_name ()
* Sqlite3_column_table_name16 ()
* Sqlite3_column_origin_name ()
* Sqlite3_column_origin_name16 ()
* Sqlite3_table_column_metadata ()
It turns out that only when this macro is enabled will the C code be used to define these functions. OK, add sqlite_enable_column_metadata To The Preprocessor, as shown in.
Compile it again!
View Original