MSVC 编译生成 SQLite3

  SpatiaLite 可以说是 SQLite 的空间扩展,要编译 libspatialite 必然需要先编译 SQLite。

版本

Visual Studio: 2015

SQLite: 3.18.0

编译生成

第 1 步

  下载 sqlite-amalgamation-3180000.zip(不必下载包含 autoconf 的版本),解压到目标文件夹。

第 2 步

  参考官方的 OSGeo4W packaging how-to 中的 build libsqlite,下载 nmake.optmakefile.vc,并复制到 …\sqlite-amalgamation-3180000\ 文件夹中。

  编辑 nmake.opt,修改 INSTDIR 为目标文件夹。

第 3 步

  编辑 sqlite3.c,在第 25 行插入:

1
2
3
#ifdef DLL_EXPORT
#define SQLITE_API __declspec(dllexport)
#endif

第 4 步

  管理员身份打开 VS2015 Native Tools Command Prompt(根据实际需要选择 x86 或 x64)。

1
2
3
cd sqlite-amalgamation-3180000
nmake /f makefile.vc
nmake /f makefile.vc install

  执行完成后,即可在 ${INSTDIR} 目录下找到编译生成的头文件、静态链接和动态链接。