Windows平台编译SQLite 3

时间:2021-11-02 08:37:34

由于需要sqlite的x64版本只能自己编译,下载sqlite源代码、sqlite.def。Visual Studio 2013新建一个Visual C++ Empty Project,Configuration Type设置为Dynamic Library (.dll)。Linker -> Input -> Module Definition File设置为sqlite3.def。考虑Windows XP的兼容性,将Platform Toolset设置为Visual Studio 2010 (v100)。编译时会有以下两个相关错误:

1、fatal error LNK1120: 7 unresolved externals

>Linking...
>sqlite3.def : error LNK2001: unresolved external symbol sqlite3_column_database_name
>sqlite3.def : error LNK2001: unresolved external symbol sqlite3_column_database_name16
>sqlite3.def : error LNK2001: unresolved external symbol sqlite3_column_origin_name
>sqlite3.def : error LNK2001: unresolved external symbol sqlite3_column_origin_name16
>sqlite3.def : error LNK2001: unresolved external symbol sqlite3_column_table_name
>sqlite3.def : error LNK2001: unresolved external symbol sqlite3_column_table_name16
>sqlite3.def : error LNK2001: unresolved external symbol sqlite3_table_column_metadata

Preprocessor Definitions添加SQLITE_ENABLE_COLUMN_METADATA即可。

2、unresolved external symbol sqlite3_rtree_geometry_callback

Preprocessor Definitions添加SQLITE_ENABLE_RTREE即可。