Version 7 (modified by Cas, 10 years ago) (diff)

b2 replaces bjam

This page is for edge cases where libtorrent is needing to be built from source. Always check the libtorrent docs for any updates to build procedures.


  1. Download libtorrent source tarball and extract it:
  1. Get the dependencies for libtorrent
    sudo apt-get build-dep libtorrent-rasterbar
  1. Build (in the extracted tarball dir):
    ./configure --enable-python-binding

Note: If the source code is from svn so you would need to create the configure script by runnning the autotool script: ./

  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, you may need to run sudo ldconfig or ensure python is searching the path to the library.


  1. Install the following:
  1. Download source tarballs and extract to path without space e.g. C:\ drive:
  1. Build boost - Open a command prompt and execute the following commands:
    Note: Building Boost takes a while and can use several gigabytes of space.
  1. Edit C:\boost\tools\build\v2\user-config.jam to force msvc version:
   using msvc : 9.0 ;
  1. Open Visual Studio command prompt
    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 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 msvc-9.0 optimization=space encryption=openssl

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

Non-python build instructions for reference: Leechcraft and QBittorrent

Debugging libtorrent on Windows



Install only debug tools

Build libtorrent with debug enabled (edit release to debug)


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

The following command after a crash:

!analyze -v -f

Symbols will be in: C:\libtorrent-rasterbar-0.16.6\bindings\python\bin\msvc-9.0\debug\boost-source\geoip-static\link-static\optimization-space\threading-multi