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

--

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.

Ubuntu

  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
    make
    

Note: If the source code is from svn so you would need to create the configure script by runnning the autotool script: ./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. Install these packages:
  1. Download source tarballs and extract to path without space e.g. C:\ drive:
  1. Boost build - Open a command prompt and execute the following commands:

If using 'Compiler for Python' you need to run vcvarsall.bat to setup compiler paths.

  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 (i.e. C:\boost) with the following to force msvc version:
       using msvc : 9.0 ;
    
  1. libtorrent Build:
    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 directory.

Non-python build instructions for reference: Leechcraft and QBittorrent

Debugging libtorrent on Windows

References:

Download:

Install only debug tools

Build libtorrent with debug enabled (edit setup.py release to debug)

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

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

srv*;C:\libtorrent-rasterbar-0.16.6\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