Visual Studio libtorrent

From LimeWire
Jump to: navigation, search


How to Build libtorrent in Visual Studio

for Fun and Profit do section building with BBv2 out of date down code and project


Windows XP SP3 and Windows Update
Visual Studio 2008 and SP1
Windows SDK Version 7, published July 24 2009

----snapshot vs2008----

Cygwin including perl


Place Code download a file like openssl-0.9.8l.tar.gz
Unzip to path like:
C:\openssl\Makefile.bak download a file like
Unzip to path like:
C:\boost_1_42_0\boost-build.jam find the highest numbered tag

svn co libtorrent

Move to path like

----snapshot a----

Make bjam

Visual Studio 2008 Command Prompt

cd C:\boost_1_42_0\tools\jam\src

Creates the file:
Copy bjam.exe to the build folder, alongside the v2 folder:

Open in Notepad:
Uncomment the line using msvc ;

Build libraries

Visual Studio 2008 Command Prompt

set PATH=%PATH%;C:\boost_1_42_0\tools\build;C:\cygwin\bin

Build OpenSSL

cd C:\openssl
perl Configure --openssldir=C:/openssl VC-WIN32
nmake -f ms\nt.mak > result1.txt
nmake -f ms\nt.mak test > result2.txt
nmake -f ms\nt.mak install > result3.txt

Build boost

cd C:\boost_1_42_0
bjam --toolset=msvc link=static runtime-link=static variant=debug > result4.txt
bjam --toolset=msvc link=static runtime-link=static variant=release > result5.txt

Build libtorrent

cd C:\libtorrent
set BOOST_ROOT=C:\boost_1_42_0
set INCLUDE=%INCLUDE%;C:\openssl\include
set LIB=%LIB%;C:\openssl\out32
bjam --toolset=msvc boost=source link=static runtime-link=static variant=debug character-set=unicode --without-python > result6.txt
bjam --toolset=msvc boost=source link=static runtime-link=static variant=release character-set=unicode --without-python > result7.txt

Move libtorrent.lib

Move from:
Rename to:

----snapshot b----

Visual Studio

New Project

Visual Studio 2008
File, New, Project
Project types: Visual C++, Win32, Win32 Project
Name: ltorrent
Location: C:\Documents
Uncheck Create directory for solution
Application Settings, check Empty Project

Project, Add Existing Item
select all the .h files, Add
Do it again for the .cpp files

Include and Lib

Tools, Options, Projects and Solutions, VC++ Directories

Include files

  • C:\openssl\include
  • C:\boost_1_42_0
  • C:\libtorrent\include
  • C:\libtorrent\zlib

Library files

  • C:\openssl\lib
  • C:\boost_1_42_0\stage\lib
  • C:\libtorrent\lib


Project, Properties, Configuration Properties

  • General, Use of ATL: Not Using ATL
  • General, Character Set: Use Unicode Character Set
  • C/C++, Code Generation, Runtime Library: change /MDd to /MTd and /MD to /MT to get rid of dll
  • C/C++, Precompiled Headers, Create/Use Precompiled Header: Not Using Precompiled Headers
  • Linker, Manifest File, Generate Manifest: No
  • Manifest Tool, Input and Output, Embed Manifest: No

At the end, check all with Configuration Debug and Release

Where other things live

  • C/C++, Preprocessor, Preprocessor Definitions (like WIN32_LEAN_AND_MEAN)
  • C/C++, Command Line
  • Linker, Command Line

Linker, Input, Additional Dependencies, Debug

  • advapi32.lib
  • comctl32.lib
  • ssleay32.lib
  • libeay32.lib
  • libboost_date_time-vc90-mt-sgd.lib
  • libboost_filesystem-vc90-mt-sgd.lib
  • libboost_system-vc90-mt-sgd.lib
  • libboost_thread-vc90-mt-sgd.lib
  • libtorrent-debug.lib


  • advapi32.lib
  • comctl32.lib
  • ssleay32.lib
  • libeay32.lib
  • libboost_date_time-vc90-mt-s.lib
  • libboost_filesystem-vc90-mt-s.lib
  • libboost_system-vc90-mt-s.lib
  • libboost_thread-vc90-mt-s.lib
  • libtorrent-release.lib

Maybe try later

  • Configuration Release, General, Whole Program Optimization: Yes
  • Configuration Release, C/C++, Optimization, Optimization: Minimize Size 01

Optional steps to start the resources from scratch

  • menu File, Add New Item
  • choose Resource File (.rc), enter name, Open


Add Code

Drop libtorrentwrapper.cpp next to Hello.cpp
C:\Documents\Visual Studio 2008\Projects\Hello\libtorrentwrapper.cpp
Project, Add Existing Item, libtorrentwrapper.cpp, Add

Comment out class blacklist_ip_filter_callback and fix errors

----snapshot c----


just for common controls, the runtime is already inside the exe



1                       RT_MANIFEST             "ltorrent.exe.manifest"
#endif    // English (U.S.) resources

Personal tools