Author: Stephan Jau
Revision: v1.2 
Last Change: February 16 2010


rTorrent is a popular command line based bittorrent client. It provides very powerful features yet it is very light on the system - contrary to other bittorrent clients like Vuze. There are a couple of webinterfaces for it but they are not truly need. SSH access combined with the "screen" program provide you all the tools you need.

Recently a large bittorrent tracker announced, that they will in future only support magnet link. Magnet links are special URLs that contain a hash link that identifies the according .torrent file. By default, rtorrent does not support magnet links. However there is a patch for it provided by Josef. The patch itself is currently split up into 3 seperate patches. This howto provides a step-by-step guide on how to compile rtorrent from svn and applying the magnet link patches (as well as two other patches I am fond of).

This howto works for Ubuntu 9.10 Karmic Koala and for Debian 5 Lenny. The difference is that commands that contain sudo must be executed as root.

In this howto I assume you download and compile the sources from your ~/rtorrent resp. ~/rtorrent/trunk folder.


1. Remove current rtorrent installation

sudo apt-get remove rtorrent libtorrent*


2. Install necessary packages

sudo apt-get install subversion build-essential libtool automake openssl libsigc++-2.0-dev libncurses5-dev libcurl4-openssl-dev


3. Create rtorrent folder

mkdir ~/rtorrent


4. Go into the rtorrent folder

cd ~/rtorrent

Current location: /home/USER/rtorrent


5. Get the rtorrent sources by svn

svn co svn://

Current rtorrent version is: rev. 1105.


6. Get into the trunk folder

cd trunk

Current location: /home/USER/rtorrent/trunk


7. Download the patches

For Magnet Link support:


As mentioned before the magnet link patch was supplied by Josef. The magnet link patches are still in development but enough stable to use them already. For more info on the development go here:

Colour support for rtorrent:


If you're on rev. 1131 then use this patch here. I don't exactly know at what revision the original patch fails. If in doubt update your rtorrent version to the latest revision. Thx to the Italian_Plumber for supplying the updated patch.


This patch enables you to colorize the rtorrent cli interfaces. It differentiaties between completed/uncompleted torrents and active/inactive ones. I first had to get used to it also but meanwhile I think it's really a good enhancement. The patch was originally supplied here: However that patch does not work with the current rev. 1105. Because of that I fixed it and supply it also from my server.

Torrent Tracker Stats:


This patch shows the number of seeders/leechers/completed as supplied by the tracker in the tracker view. Often it's not accurate however it's usefull for me to check if a tracker has any peers at all listed for a given torrent.


8. Apply the patches

Magnet link support:

patch -p0 < dht-pex-static_map.diff
patch -p0 < magnet-uri.diff
patch -p0 < object-sstr.diff

If the first patch gives an error like this:

patching file libtorrent/src/torrent/
Hunk #1 FAILED at 41.
Hunk #2 FAILED at 77.
2 out of 2 hunks FAILED -- saving rejects to file libtorrent/src/torrent/

Then you'll have to download another custom patch also and apply it. The reason is, that the libtorrent has changed and the patch by Josef does not yet reflect that change. In time Josef will update his patch. So make sure that the above error message appears before running the patch below. My fix has been tested on revision 1117.

patch -p0 < dht-pex-static_map_rev1117.diff

Colour support for rtorrent:

patch -p0 < canvas-color.patch

Torrent Tracker Stats:

patch -p0 < trackerinfo.patch


9. Get into the libtorrent folder

cd libtorrent

Current location: /home/USER/rtorrent/trunk/libtorrent


10. Run the script



11. Configure libtorrent



12. Compile libtorrent



13. Install libtorrent

sudo make install


14. Extend /etc/

echo "include /usr/local/lib" | sudo tee -a /etc/


15. Updated cache

sudo ldconfig


16. Get into the rtorrent folder

cd ../rtorrent

Current location: /home/USER/rtorrent/trunk/rtorrent


17. Run the script



18. Configure rtorrent



19. Compile rtorrent



20. Install rtorrent

sudo make install


21. Extend rtorrent configuration

Magnet Link support as provided by this howto requires a session folder. If there is no session folder defined yet in the ~/.rtorrent.rc config file or if that config file does not exist yet, then it has to be added. An example for an ~/.rtorrent.rc file can be found here: In addition I would also set the DHT option to "on".

You can also just copy the .rtorrent.rc config file from the trunk and then edit it:

cp ~/rtorrent/trunk/rtorrent/doc/rtorrent.rc ~/.rtorrent.rc

To make use of the colour patch, also the colour options need to be added to the ~/.rtorrent.rc config. I use this example below:

# Color / Canvas patch
done_fg_color = 2
#done_bg_color = 2
active_fg_color = 1
#active_bg_color = 4

With these options inactive completed torrents will be displayed as dark green, active ones as bright green, inactive incompleted torrents are displayed in dark red, active ones in bright red. To customize this further you can use those colours: 0 = black; 1 = red; 2 = green; 3 = yellow; 4 = blue; 5 = magenta; 6 = cyan; 7 = white


22. Run rtorrent



The use is actually quite simple. In rtorrent press the backspace or enter key and then paste the magnet link url. The difference between the backspace and enter key is, that backspace auto-starts the magnet link and enter just add it but does not start it.

To make rtorrent auto-fetch magnet links that you click on you can use this bash script provided also by Josef:

cd ~/watch    # set your watch directory here
[[ "$1" =~ xt=urn:btih:([^&/]+) ]] || exit;
echo "d10:magnet-uri${#1}:${1}e" > "meta-${BASH_REMATCH[1]}.torrent"

Save that script somewhere in your home folder e.g. ~/ and make it executable. Then tell your browser that when a magnet link is clicked, that this script should be run (or the magnet link be opened by this script). I did not try it myself but I have faith in Josef's abilities as it was him who actually supplied the magnet link patch.

Share this page:

Suggested articles

16 Comment(s)

Add comment


By: dywany

Very good post, thanks a lot.

By: dywany

Indeed, great post :)


By: Anonymous

Great guide, thanks. You might want to update the svn checkout to manually specify revision 1105:

 svn co  svn:// --revision 1105

 as the latest SVN trunk is revision 1110 which will fail to compile.


I just updated the howto. Added a custom patch that makes it work again in rev 1117 (and possibly older versions).

By: Simon Evans

That makes my favourite BitTorrent client even better.  Combined with rtGui (an rTorrent web interface), it's just awsome :)

By: Anonymous

rtorrent with colors and magnet links support is great.

Thank you for this howto and the developers of rtorrent :)

By: pconwell

At step 22 I got: "rtorrent: XMLRPC not supported."

I had to back up to step 18 and do "./configure --with-xmlrpc-c" to fix it.

By: Anonymous

Looks like is down. Anyone have an alternate location for the patches. I did find magnet-hex-hash.diff in the google cache but none of the others.

By: Anonymous

this is my first time trying to comile anything and install so i may have done something wrong outside of this guide. i followed all of teh steps exactly and everythign was working fine until i issued the make command on step 19. this is the output from the make command

[email protected]:~/rtorrent/trunk/rtorrent$ make
make  all-recursive
make[1]: Entering directory `/home/aaron/rtorrent/trunk/rtorrent'
Making all in doc
make[2]: Entering directory `/home/aaron/rtorrent/trunk/rtorrent/doc'
make[2]: Nothing to be done for `all'.
make[2]: Leaving directory `/home/aaron/rtorrent/trunk/rtorrent/doc'
Making all in src
make[2]: Entering directory `/home/aaron/rtorrent/trunk/rtorrent/src'
Making all in core
make[3]: Entering directory `/home/aaron/rtorrent/trunk/rtorrent/src/core'
g++ -DHAVE_CONFIG_H -I. -I../.. -I. -I./.. -I../..    -g -O2 -g -DDEBUG -I/usr/include/sigc++-2.0 -I/usr/lib/sigc++-2.0/include     -I/usr/local/include   -MT curl_socket.o -MD -MP -MF .deps/curl_socket.Tpo -c -o curl_socket.o
In file included from /usr/local/include/torrent/peer/peer_info.h:40,
                 from /usr/local/include/torrent/peer/peer.h:42,
                 from /usr/local/include/torrent/download.h:47,
                 from /usr/local/include/torrent/torrent.h:43,
                 from ./../control.h:44,
/usr/local/include/torrent/hash_string.h:47:35: error: torrent/simple_string.h: No such file or directory
In file included from /usr/local/include/torrent/peer/peer_info.h:40,
                 from /usr/local/include/torrent/peer/peer.h:42,
                 from /usr/local/include/torrent/download.h:47,
                 from /usr/local/include/torrent/torrent.h:43,
                 from ./../control.h:44,
/usr/local/include/torrent/hash_string.h:89: error: ‘SimpleString’ does not name a type
/usr/local/include/torrent/hash_string.h:102: error: expected ‘,’ or ‘...’ before ‘&’ token
/usr/local/include/torrent/hash_string.h: In static member function ‘static const torrent::HashString* torrent::HashString::cast_from(int)’:
/usr/local/include/torrent/hash_string.h:102: error: ‘src’ was not declared in this scope
make[3]: *** [curl_socket.o] Error 1
make[3]: Leaving directory `/home/aaron/rtorrent/trunk/rtorrent/src/core'
make[2]: *** [all-recursive] Error 1
make[2]: Leaving directory `/home/aaron/rtorrent/trunk/rtorrent/src'
make[1]: *** [all-recursive] Error 1
make[1]: Leaving directory `/home/aaron/rtorrent/trunk/rtorrent'
make: *** [all] Error 2

im not sure what went wrong any help would be much appreciated. 


Better to ask in the forum and hit me up with a PM when you do so.

By: Anonymous

Als Is there any way by which my program (c program having inf_hash ) come to know that seeding of torrent against info_hash is started…….??
How to do this ?


Any Help would be aapretiated

By: Anonymous

I had to install this too in step 2 (using ubuntu 9.10 server) sudo apt-get install libxmlrpc-c3-dev to get the --with-xmlrpc-c flag for ./configure to work for rtorrent.

By: Petroffich

Thank a lot for your post! I used it myself and made translation for russian torrent tracker ( rtorrent supports magnet url starting with r1144. Color patch is changed slightly, here it is for r1144-r1148 :

By: Italian_Plumber

Very helpful.  Thanks!

I'm getting a 404 not found from wget when trying to download those patches, could they have been moved or renamed?

By: Anonymous

might think of adding libcppunit-dev to packages required to install if you run in to compilation problems of libtorrent