Version 21 (modified by Cas, 8 years ago) (diff) |
---|
Build libtorrent from source
Check libtorrent documentation for any updates to build procedures.
Ubuntu / Debian
- Install dependencies for libtorrent build automatically using build-dep:
sudo apt-get build-dep libtorrent-rasterbar sudo apt-get install checkinstall
OR if that fails manually install them:
sudo apt-get install build-essential checkinstall libboost-system-dev libboost-python-dev libssl-dev libgeoip-dev
- Download libtorrent and extract:
tar xf libtorrent-rasterbar.tar.gz cd libtorrent-rasterbar
- Configure:
./configure --enable-python-binding --with-libgeoip --with-libiconv
- Logging: Add --enable-logging=default to get logs in the current working directory. verbose and error can also be used.
- Debug: To create a debug build add --enable-debug=yes.
- VCS: For source code directly from git, run ./autotool.sh to create the configure script (requires autoconf, automake & libtool packages).
- Build:
make -j$(nproc)
- CPU Cores: The make option -j$(nproc) will utilize all available cpu cores.
- Install library and python bindings:
sudo checkinstall sudo ldconfig
Substituted make install for checkinstall as it creates a deb package for easier removal/re-install by dpkg.
Running ldconfig avoids an ImportError for libtorrent-rasterbar.so, a result of Python being unable to find the main library.
- Verify libtorrent and the python bindings are installed correctly:
python -c "import libtorrent; print libtorrent.version" >> 1.0.6.0
Windows
- Download and install/extract these packages:
Note: Install or extract to a path without spaces e.g. C:\ drive.
- Setup the Windows Command Prompt by executing VC for Python vcvarsall.bat, e.g.:
"%USERPROFILE%\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat"
Note: If using Visual Studio simple open a Visual Studio 2008 Command Prompt.
- Boost Build Steps:
Due to a boost bug with VC for Python, need to edit project-config.jam in boost folder to the following:
using msvc : : : <setup>"%USERPROFILE%\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\vcvarsall.bat" ;In the boost directory run the following:
bootstrap.bat b2 --with-system --with-date_time --with-python
- Create a Boost user-config.jam file in the toplevel folder (e.g. C:\boost) with the following to force msvc version:
using msvc : 9.0 : : <setup>"%USERPROFILE%\\AppData\\Local\\Programs\\Common\\Microsoft\\Visual C++ for Python\\9.0\\vcvarsall.bat" ;
Note: For Visual Studio, simply using msvc : 9.0 ; is required.
- libtorrent Build Steps:
- Setup the Environmental Variables:
set INCLUDE=C:\OpenSSL-Win32\include;%INCLUDE% set LIB=C:\OpenSSL-Win32\lib;%LIB% set BOOST_BUILD_PATH=C:\boost set PATH=%BOOST_BUILD_PATH%;%PATH%
- Navigate to libtorrent Python bindings folder:
cd C:\libtorrent-rasterbar\bindings\python
- Build libtorrent with Python bindings:
b2 boost=source link=static geoip=static boost-link=static release optimization=space encryption=openssl
- Setup the Environmental Variables:
Upon a successful build the library file named libtorrent.pyd is created in the current bindings/python directory.
Debugging libtorrent on Windows
- Download and install just the debug tools:
- Build libtorrent with debug enabled by changing release to debug in the b2 build line.
- Open windbg (C:\Program Files\Debugging Tools for Windows (x86)\windbg.exe):
- File|Open Executable and tick Debug child processes
- Hit F5 or Go a few times to get the program running
- After the crash execute: !analyze -v -f.
- Symbols for libtorrent will be in the build output path:
C:\libtorrent-rasterbar\bindings\python\bin\msvc-9.0\debug\boost-source\geoip-static\link-static\optimization-space\threading-multi
So the full symbols line should look something like this:srv*;C:\libtorrent-rasterbar\bindings\python\bin\msvc-9.0\debug\boost-source\geoip-static\link-static\optimization-space\threading-multi;C:\Python27\symbols;srv*c:\Symbols*http://msdl.microsoft.com/download/symbols
Debug References: