P2P 开发环境搭建

1. 搭建tracker

https://github.com/chihaya/chihaya     下载后,可以按说明编译出 chihaya.exe ,也可以载入GoLang, 按照编译是的提示,

go  get     ,安装缺少的依赖包。

运行后,启动

 "starting HTTP frontend" addr="0.0.0.0:6969"

“starting UDP frontend" addr="0.0.0.0:6969”

announce接口    http://127.0.0.1:6969/announce       udp://127.0.0.1:6969/announce

 

2.  编译boost

git clone https://github.com/openssl/openssl.git


1. compile openssl
可能需要先安装http://www.nasm.us/pub/nasm/releasebuilds/2.11.02/win32/nasm-2.11.02-installer.exe
copy nasm  ndisasm  C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin

perl Configure VC-WIN32
call ms\do_nasm
 这里可以提前修改ms目录下的ntdll.mak文件,把-w3修改为-w0:
            CFLAG= /MD /Ox -DOPENSSL_THREADS  -DDSO_WIN32 -W3 -Gs0 -Gy -nologo 
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\bin\vcvars32.bat"
编译静态版本的执行nmake -f ms/nt.mak       在 out32/先生成  openssl.exe libeay32.lib ssleay32.lib
编译动态版本的执行nmake -f ms/ntdll.mak    在 out32dll   openssl.exe libeay32.dll,ssleay32.dll 

2. compile boost
download boost_1_66_0.zip
extract 
cd   boost_1_66_0
执行 boostrap.bat   在当前目录下生成 b2.exe,bjam.exe,project-config.jam。
使用bjam编译
 #bjam --without-python --toolset=msvc-14.0 link=static runtime-link=shared  threading=multi debug release
 bjam --without-python --toolset=msvc-14.0 link=shared runtime-link=shared  threading=multi debug release

 

3. 编译 libtorrent C++版

 
 set BOOST_BUILD_PATH=E:\CLIB\boost_1_66_0
 
 set BOOST_ROOT=E:\CLIB\boost_1_66_0
 
 下面两行不确定有用?
 set INCLULDE=E:\CLIB\libtorrent\libtorrent-libtorrent-1_2_1\include;E:\CLIB\openssl-1.0.2n\include\;E:\CLIB\boost_1_66_0\boost\;
 set LIB=E:\CLIB\openssl-1.0.2n\out32\;E:\CLIB\boost_1_66_0\stage\lib

#2 msvc-14.0 link=static runtime-link=static
b2 msvc-14.0 link=shared  runtime-link=shared

 msvc.link.dll bin\msvc-14.0\debug\threading-multi\torrent.dll
  正在创建库 bin\msvc-14.0\debug\threading-multi\torrent.lib 和对象 bin\msvc-14.0\debug\threading-multi\torrent.exp
msvc.manifest.dll bin\msvc-14.0\debug\threading-multi\torrent.dll

 

4. 使用VS编译 libtorrent example时,

设置相关的 boost libtorrent  include 路径,导入相关的 boost  libtorrent动态库。

 

5. 编译 libtorrent python

使用 libtorrent-rasterbar-1.2.1.tar 源码包

使用python36   32位


building using boost build (windows)
Download and install Visual C++ 2015 Build Tools

Download Boost libraries Extract it to E:/Libraries/boost_1_66_0 and create these environmental vars:

set PATH=%PATH%;E:\CLIB\boost_1_66_0/tools/build/src/engine/bin.ntx86/
set BOOST_BUILD_PATH=E:\CLIB\boost_1_66_0\tools\build
set BOOST_ROOT=E:\CLIB\boost_1_66_0

Move the file user-config.jam from %BOOST_BUILD_PATH%/example/ to %BOOST_BUILD_PATH%/user-config.jamand add this at the end:

using msvc : 14.0 : : /std:c++11 ;   # 这个配置会报错,改为  using msvc ;
using python : 3.5 : C:/Users//AppData/Local/Programs/Python/Python35 : C:/Users//AppData/Local/Programs/Python/Python35/include : C:/Users//AppData/Local/Programs/Python/Python35/libs ;

(change the python path for yours)

 

如果出现  Cannot determine the location of the VS Common Tools folder
在环境变量PATH中添加     C:\Windows\System32

reference::  https://www.libtorrent.org/python_binding.html#building-using-boost-build-windows

cd  E:\CLIB\libtorrent\libtorrent-rasterbar-1.2.1\bindings\python/bindings/python
python setup.py build --bjam

生成  libtorrent.pyd

问题:

使用libtorrent.pyd时发现,无法识别很多torrent参数,比如

'seed_mode': True, 'upload_mode':True

可以下载 https://github.com/Tribler/libtorrent-binaries/blob/master/libtorrent.pyd  

这是一个 64位的python 2的加密库

你可能感兴趣的:(P2P)