我的博客

Windows下编译安装py-leveldb

目录
  1. 编译 LevelDB
  2. 编译 Snappy
  3. 编译 py-leveldb-windows

使用环境 Windows 10,VS 2019(VS 16)

编译 LevelDB

https://github.com/google/leveldb

启动Developer Command Prompt for VS 2019

1
2
3
4
5
git clone --recurse-submodules https://github.com/google/leveldb.git
cd leveldb
mkdir build && cd build
cmake -G "Visual Studio 16" ..
msbuild /m /p:Platform=x64,Configuration=Release leveldb.sln

然后得到leveldb\build\Release\leveldb.lib

编译 Snappy

https://github.com/google/snappy

1
2
3
4
5
git clone https://github.com/google/snappy.git
git submodule update --init
mkdir build && cd build
cmake -G "Visual Studio 16" ..
msbuild /m /p:Platform=x64,Configuration=Release Snappy.sln
1
msbuild /m /p:Platform=x64,Configuration=Release leveldb_ext.sln

编译 py-leveldb-windows

https://github.com/happynear/py-leveldb-windows

1
2
3
4
5
6
7
8
set INCLUDE=C:\Users\v-xiaowensun\AppData\Local\Programs\Python\Python39\include;%INCLUDE%

set INCLUDE=D:\include;%INCLUDE%

set AdditionalIncludeDirectories=C:\Users\v-xiaowensun\AppData\Local\Programs\Python\Python39\include;%AdditionalIncludeDirectories%


set AdditionalLibraryDirectories=C:\Users\v-xiaowensun\AppData\Local\Programs\Python\Python39\libs;%AdditionalLibraryDirectories%

以上配置都无效不知为何并没有起效,最终打开工程文件把D:\Anaconda\include替换为C:\Users\v-xiaowensun\AppData\Local\Programs\Python\Python39\include

D:\Anaconda\libs替换为C:\Users\v-xiaowensun\AppData\Local\Programs\Python\Python39\libs

D:\ThirdPartyLibrary\pyleveldb\leveldbwin\lib_leveldb_vc10\lib\Release替换为C:\Users\v-xiaowensun\codes\leveldb\build\Release

再添加C:\Users\v-xiaowensun\codes\snappy\build\Release

Python 头文件路径:C:\Users\v-xiaowensun\AppData\Local\Programs\Python\Python39\include

Python 静态库路径:C:\Users\v-xiaowensun\AppData\Local\Programs\Python\Python39\libs

评论无需登录,可以匿名,欢迎评论!