Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

SQLite lesson 2 download and compile

2025-01-15 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

Document description

Download two source packages:

Sqlite-dll-win32-x86-3081101.zip, which provides the file sqlite3.def that exports the functions of sqlite3

Mainly used to generate LIB files to determine the use of links

Sqlite-preprocessed-3081101.zip, provides source files, but deletes shell.c and tclsqlite3.c files

Shell.c: provides a main function entry to generate an executable program for sqlite.exe, and the generated console operates the SQLite database

Tclsqlite.c: provides a TCL script for testing SQLite on Linux systems

These two files are windows for the compilation environment, but you don't need to compile SQLite into the program, and you need to delete them when you add the source code.

Sqlite3.h: provides all interfaces for external use

Sqlite3ext.h: this file is not understood for the time being

* * This header file defines the SQLiteinterface for use by

* * shared libraries that want to beimported as extensions into

* * an SQLite instance. Shared libraries that intend to be loaded

* * as extensions by SQLite should # includethis file instead of

* * sqlite3.h.

2 description of compilation options

Required compilation options:

SQLITE_CORE

FTS1 has a design flaw that can lead to database errors (databasecorruption). It is highly recommended to abandon this module and use fts3 or higher modules instead. If you believe that fts1 is safe to use, you can add DSQLITE_ENABLE_BROKEN_FTS1=1 to the compilation option.

The FTS1 module will be compiled as an extension module (when SQLITE_CORE is not defined).

In addition, if SQLITE_ENABLE_FTS1 is defined, FTS1 will also be compiled into the SQLite kernel.

Optional compilation options:

SQLITE_ENABLE_RTREE

The Rtree module is compiled into the SQLite kernel, and the POI in two-dimensional space is stored in this study.

Therefore, the Rtree module must be opened, and the source code will be parsed later.

SQLITE_ENABLE_COLUMN_METADATA

Function: you can call the following function

SQLITE_API const char * SQLITE_STDCALL sqlite3_column_database_name (sqlite3_stmt*,int)

SQLITE_API

Const void * SQLITE_STDCALL sqlite3_column_database_name16 (sqlite3_stmt*,int)

SQLITE_API const

Char * SQLITE_STDCALL sqlite3_column_table_name (sqlite3_stmt*,int)

SQLITE_API const void

* SQLITE_STDCALL sqlite3_column_table_name16 (sqlite3_stmt*,int)

SQLITE_API const char

* SQLITE_STDCALL sqlite3_column_origin_name (sqlite3_stmt*,int)

SQLITE_API const void

* SQLITE_STDCALL sqlite3_column_origin_name16 (sqlite3_stmt*,int)

These functions mainly obtain the database name, table name, and column name.

Call condition: it must be called after [sqlite3_step ()] and before [sqlite3_finalize ()].

1. Create a new win32 console program, named sqlite3

two。 Choose to generate DLL

3. Extract the package and copy the sqlite-preprocessed-3081101 files to the project folder (except for shell.c and tclsqlite.c).

4. Add the source code to the compiled project by adding the existing file

5 set the module definition file sqlite3.def, otherwise the generated dll does not have a corresponding lib

Specify the export file of the function: sqlite3.defs

Properties > > Linker > > input > > Module definition file (sqlite3.def), note that in this case, the sqlite3.def file and the compilation environment level.

6. Add predefined options SQLITE_CORE,SQLITE_ENABLE_COLUMN_METADATA, SQLITE_ENABLE_RTREE, which is the macro definition of sqlite3.

Attribute > > Candlespace + > > preprocessor > > preprocessing definition > >

SQLITE_CORE

SQLITE_ENABLE_COLUMN_METADATA

SQLITE_ENABLE_RTREE

Compilation error prompt:

1 > sqlite3.def: error LNK2001: unparsed external symbol sqlite3_column_database_name

1 > sqlite3.def: error LNK2001: unparsed external symbol sqlite3_column_database_name16

1 > sqlite3.def: error LNK2001: unparsed external symbol sqlite3_column_origin_name

1 > sqlite3.def: error LNK2001: unparsed external symbol sqlite3_column_origin_name16

1 > sqlite3.def: error LNK2001: unparsed external symbol sqlite3_column_table_name

1 > sqlite3.def: error LNK2001: unparsed external symbol sqlite3_column_table_name16

1 > sqlite3.def: error LNK2001: unparsed external symbol sqlite3_rtree_geometry_callback

1 > sqlite3.def: error LNK2001: unparsed external symbol sqlite3_rtree_query_callback

The first six functions must be defined with SQLITE_ENABLE_COLUMN_METADATA before they can be exported. In general, we can delete these functions directly in the sqlite3.def file without exporting them.

For the last two functions, SQLITE_ENABLE_RTREE must be defined before they can be exported. If we do not apply the spatial search function of R-tree, we can delete these functions directly in the sqlite3.def file without exporting them.

7. Press F7 to generate the corresponding dll and lib.

Compilation description

1) fts2 has a designflaw and has been deprecated

2) fts1 has a designflaw and has been deprecated

Solution:

Analysis: both FTS1 and FTS2 have design defects and have now been abandoned, and FTS3 or FTS4 has been provided as a full-text search module, which makes up for the shortcomings of the previous FTS1. If you are sure that full-text search will not be used, you can use SQLITE_CORE directly and disable it. Add SQLITE_CORE to the compilation option.

Basic settings of VS: properties > > C _ CPG + > > preprocessor "" preprocessing definition

3) Cannot open includefile: 'unicode/utypes.h': No such file or directory

This problem is mainly caused by calling FTS1 or FTS2, which is compiled successfully by disabling FTS1 and FTS2.

FTS1 has a design flaw that can lead to database errors (databasecorruption). It is highly recommended to abandon this module and use fts3 or higher modules instead. If you believe that fts1 is safe to use, you can add DSQLITE_ENABLE_BROKEN_FTS1=1 to the compilation option.

The FTS1 module will be compiled as an extension module (when SQLITE_CORE is not defined).

In addition, if SQLITE_ENABLE_FTS1 is defined, FTS1 will also be compiled into the SQLite kernel.

4) Error: no module:rtree

By default, the console program of sqlite3.exe does not carry the Rtree module. If you need to enable this module, you need to call the precompiled definition: SQLITE_ENABLE_RTREE, and then regenerate the program through the main of the shell.c file.

5) console program

Set up an empty console, then import the sqlite source code, and the following error occurs in the compilation:

Error LNK2019: unparsed external symbol _ WinMain@16, which is in the function _ tmainCR...

Step 1: add: SQLITE_ENABLE_RTREE parameter supports rtree in clocked codes / precompiling

Step 2: if it is a console program:

1. Select Project- > Properties from the menu to pop up the Property Pages window

two。 In the left column, select: ConfigurationProperties- > C _ CONSOLE categories-> Preprocessor, then delete _ WINDOWS from the item corresponding to PreprocessorDefinitions in the right column and add _ CONSOLE.

3. Select ConfigurationProperties- > Linker- > System in the left column, and then change the item corresponding to SubSystem in the right column to CONSOLE (/ SUBSYSTEM:CONSOLE)

6) unexpected end offile while looking for precompiled header. Did you forget to add'# include "stdafx.h" to your source?

The SQLite source code cannot call the precompilation process because the SQLite source code is a pure C language and cannot gain the benefits of VC++ precompilation.

Resolve: properties > > Cramp + > > precompiled headers > > create and use precompiled headers (without precompiled headers)

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report