Version 13 (modified by Cas, 9 years ago) (diff)

Add a few more details for ubuntu build and tidy the page header

Build libtorrent from source

Remember to check the libtorrent documentation for any updates to build procedures.

Ubuntu / Debian

  1. Download libtorrent source tarball and extract it:
  1. Get the dependencies for libtorrent
    sudo apt-get build-dep libtorrent-rasterbar
    

For reference the usual libtorrent dependencies are:

sudo apt-get build-essential libboost-system-dev libboost-python-dev libssl-dev libgeoip-dev
  1. Build (in the extracted tarball dir):
    ./configure --enable-python-binding
    make
    

Note: For source code from svn, create the configure script by runnning: ./autotool.sh

  1. Install:
    sudo apt-get install checkinstall
    sudo checkinstall
    
    This will install libtorrent and bindings in the correct place. I have substituted checkinstall for make install because checkinstall creates a deb package that then can be used by dpkg to remove all the installed files easily.
  1. Verify libtorrent and it's python binding are installed correctly:
    python -c "import libtorrent as lt; print lt.version"
    

If you encounter an !ImportError relating to opening libtorrent-rasterbar.so, you may need to run sudo ldconfig or ensure Python is searching the correct path to the library.

Windows

  1. Install Visual Studio or just the compiler:
  1. Download and install these packages:
  1. Download source tarballs and extract to path without space e.g. C:\ drive:
  1. Boost Build Steps:

Open a Visual Studio 2008 Command Prompt
OR
If using VC++ Compiler for Python, open Windows Command Prompt and execute vcvarsall.bat, e.g.:

C:\Users\User\AppData\Local\Programs\Common\Microsoft\Visual C++ for Python\9.0\vcvarsall.bat

From Command Prompt, execute the following commands:

  bootstrap.bat
  b2

Building Boost can take a long time and uses 2-3 gigabytes of disk space.

  1. Create a Boost user-config.jam file in BOOST_ROOT (e.g. C:\boost) with the following to force msvc version:
       using msvc : 9.0 ;
    
  1. libtorrent Build Steps:
    1. Setup the Environmental Variables:
      set INCLUDE=C:\OpenSSL-Win32\include;%INCLUDE%
      set LIB=C:\OpenSSL-Win32\lib;%LIB%
      set BOOST_ROOT=C:\boost
      set BOOST_BUILD_PATH=%BOOST_ROOT%
      set PATH=%BOOST_ROOT%;%PATH%
      
    2. Navigate to libtorrent Python bindings folder:
      cd C:\libtorrent-rasterbar\bindings\python
      
    3. Build libtorrent with Python bindings:
b2 boost=source link=static geoip=static boost-link=static release optimization=space encryption=openssl

Upon a successful build the library file named libtorrent.pyd is created in the current bindings directory.

Debugging libtorrent on Windows

Note: Only need to install debug tools.

  • Build libtorrent with debug enabled by changing release to debug in setup.py or b2 line in steps above.
  • In 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
  • Execute the following command after a crash:
    !analyze -v -f
    

  • Symbols for libtorrent will be in the following 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:

Further Resources