This page describes the process of building qBittorrent on Windows targeting x86_64 (aka x64 aka AMD64 aka 64-bit) architecture. Building for x86_64 arch is only supported by Visual Studio Professional or better, Express edition won't do.
Note: Even though this article tries to be as full as possible, it is not recommended for users without basic knowledge in programming and windows shell scripting.
Final note: Resulting binary will not support Windows XP 64-bit Edition and Windows Server 2003 64-bit Edition unless you follow special notes describing how to make it compatible with those systems.
- Software Requirements
- Source Requirements
- Preparing Directory Structure
- Build Zlib
- Build OpenSSL
- Build Boost
- Build libtorrent
- Build Qt
- Build qBittorrent
- Using resulting binaries on different computers
- At least Windows 7 SP1 64-bit
- At least Visual Studio 2013 Professional Edition.
- Perl. ActiveState Perl x86 is known to work.
- Latest version of NASM assembler.
-
Latest version of Zlib.
- 1.2.8 is used in this article.
-
Latest version of OpenSSL. Be sure to download the one without fips in the name.
- 1.0.1i is used in this article.
-
Latest version of Qt. Look for
The source code is also available as a single zip
on download page. This is what you need, not the prebuilt binaries.Note: Qt5 is currently not supported by qBittorrent.
- 4.8.6 is used in this article.
-
Latest version of Boost.
- 1.56 is used in this article.
-
Latest version of libtorrent-rasterbar.
- 0.16.17 is used in this article.
-
Latest version of qBittorrent or you can Download Master Branch from GitHub.
- 3.1.9.2 is used in this article.
-
Maxmind GeoIP Database.
-
First of all you will need a working directory structure for source code and compiled binaries. Create something like that:
C:\work \sources \install
-
In this article I'm using a drive as a working directory, so I have something like that:
T: \sources \install
This directory structure will be used as an example.
-
Unpack Zlib into
\sources\zlib\
. -
Open
VS2013 x64 Native Tools Command Prompt
usually found inStart->All Programs->Visual Studio 2013->Visual Studio Tools
-
Navigate to Zlib source folder.
-
Edit
.\win32\Makefile.msc
and do the following changes:- Find the line starting with
AS
and on that line:- Replace
ml
withml64
- Replace
- Find the line starting with
ASFLAGS
and on that line:- Replace
-coff -Zi $(LOC)
with$(LOC)
- Replace
- Find the line starting with
CFLAGS
and on that line:- Replace
-nologo -MD -W3 -O2 -Oy- -Zi -Fd"zlib" $(LOC)
with-nologo -MD -O2 -w -favor:blend -GL -GR- -Y- -MP -EHs-c- $(LOC)
- Replace
- Find the line starting with
LDFLAGS
and on that line:- Replace
-nologo -debug -incremental:no -opt:ref
with-nologo -incremental:no -opt:ref -opt:icf=5 -ltcg
- Replace
- Find the line starting with
ARFLAGS
and on that line:- Replace
-nologo
with-nologo -ltcg
- Replace
- Find the line starting with
-
Build Zlib:
nmake -f .\win32\Makefile.msc AS=ml64 LOC="-DASMV -DASMINF -DNDEBUG -I." OBJA="inffasx64.obj gvmat64.obj inffas8664.obj" nmake -f .\win32\Makefile.msc test
Last command will run a short test to make sure that Zlib is working.
-
Install Zlib into
\install\zlib
folder:Technical note: because Makefile does not provide an install target, we need to do it ourselves.
IF EXIST T:\install\zlib RD /S /Q T:\install\zlib MD T:\install\zlib FOR %X IN (bin lib include) DO ( MD T:\install\zlib\%X ) XCOPY /Y /Q /I .\*.dll T:\install\zlib\bin\ XCOPY /Y /Q /I .\*.lib T:\install\zlib\lib\ XCOPY /Y /Q /I .\zconf.h T:\install\zlib\include\ XCOPY /Y /Q /I .\zlib.h T:\install\zlib\include\
-
Unpack OpenSSL into
\sources\openssl\
. -
Install Perl if you haven't. In this article Perl is installed in
T:\Perl
.It is recommended to install both perl and NASM to directory structure without spaces.
-
Open
VS2013 x64 Native Tools Command Prompt
. -
Navigate to OpenSSL source folder.
-
If you still haven't installed NASM, now is the best time. In this article NASM is installed in
T:\NASM
. -
Adjust
PATH
variable:SET "PATH=T:\NASM;%PATH%"
-
Configure OpenSSL:
perl Configure VC-WIN64A threads shared zlib -IT:\install\zlib\include -LT:\install\zlib\lib --prefix=T:\install\openssl .\ms\do_win64a.bat
-
Edit
.\ms\ntdll.mak
and do the following changes:- Find the line starting with
CFLAG=
and on that line:- Replace
/Ox
with/O2 /favor:blend /GL /Y-
- Replace
- Find the line starting with
LFLAGS=
- Replace
/debug
with/OPT:ICF=5 /LTCG
- Replace
- Find the line starting with
MLFLAGS=
- Replace
/debug
with/OPT:ICF=5 /LTCG
- Replace
- Find the line starting with
ASM=
- Remove
-g
from that line
- Remove
- Find the line containing
zlib1.lib $(EX_LIBS)
- Replace
zlib1.lib
withzlib.lib
in line
- Replace
- Find the line starting with
-
Build OpenSSL:
nmake -f .\ms\ntdll.mak
-
Optional. Test OpenSSL:
nmake -f .\ms\ntdll.mak test
Somewhere near the end of test you should see:
Available compression methods: 1: zlib compression
And in the very end you should see
passed all tests
. -
Install OpenSSL:
nmake -f .\ms\ntdll.mak install
-
Unpack Boost into
\sources\boost\
. -
Open
VS2013 x64 Native Tools Command Prompt
. -
Navigate to Boost source folder.
-
Build and install bjam (aka Boost-Build):
CD .\tools\build .\bootstrap.bat vc12 .\b2.exe --toolset=msvc architecture=x86 address-model=64 --prefix=T:\install\bjam link=shared runtime-link=shared variant=release debug-symbols=off warnings=off warnings-as-errors=off inlining=full optimization=speed "cflags=/O2 /GL /Gy /favor:blend" "linkflags=/NOLOGO /OPT:REF /OPT:ICF=5 /LTCG" install CD ..\..\
-
Build and install Boost:
SET "PATH=T:\install\bjam\bin;%PATH%" bjam -j2 -q --with-system --toolset=msvc --layout=system --prefix=T:\install\boost link=shared runtime-link=shared variant=release debug-symbols=off threading=multi address-model=64 host-os=windows target-os=windows embed-manifest=on architecture=x86 warnings=off warnings-as-errors=off inlining=full optimization=speed "cflags=/O2 /GL /favor:blend" "linkflags=/NOLOGO /OPT:REF /OPT:ICF=5 /LTCG" install XCOPY /Y /Q /I .\*.jam T:\install\boost\ COPY /Y Jamroot T:\install\boost\
-
Unpack libtorrent into
\sources\libtorrent\
. -
Open
VS2013 x64 Native Tools Command Prompt
. -
Navigate to libtorrent source folder.
-
Edit
include/libtorrent/escape_string.hpp
to fix symbol export with dynamic linking:- Replace
TORRENT_EXTRA_EXPORT std::string base32decode(std::string const& s);
with
TORRENT_EXPORT std::string base32decode(std::string const& s);
- Replace
-
Build and install libtorrent:
SET "PATH=T:\install\bjam\bin;%PATH%" bjam -j2 -q --toolset=msvc --prefix=T:\install\libtorrent boost=system boost-link=shared link=shared runtime-link=shared variant=release debug-symbols=off resolve-countries=on full-stats=on export-extra=off ipv6=on dht-support=on character-set=unicode geoip=static encryption=openssl windows-version=vista threading=multi address-model=64 host-os=windows target-os=windows embed-manifest=on architecture=x86 warnings=off warnings-as-errors=off inlining=full optimization=speed "cflags=/O2 /GL /favor:blend" "linkflags=/NOLOGO /OPT:REF /OPT:ICF=5 /LTCG" "include=T:\install\OpenSSL\include" "include=T:\install\Boost\include" "library-path=T:\install\OpenSSL\lib" "library-path=T:\install\Boost\lib" "define=BOOST_ALL_NO_LIB" install
- If you want to build For XP 64-bit or WinServer 2003 64-bit you must build with
windows-version=xp
instead ofwindows-version=vista
- If you want to build For XP 64-bit or WinServer 2003 64-bit you must build with
-
Unpack Qt into
\sources\Qt\
. -
Open
VS2013 x64 Native Tools Command Prompt
. -
Navigate to Qt source folder.
-
Build Qt:
.\configure.exe -release -shared -opensource -confirm-license -platform win32-msvc2013 -arch windows -ltcg -no-fast -exceptions -no-accessibility -stl -no-xmlpatterns -no-sql-mysql -no-sql-psql -no-sql-oci -no-sql-odbc -no-sql-tds -no-sql-db2 -qt-sql-sqlite -no-sql-sqlite2 -no-sql-ibase -no-qt3support -no-opengl -no-openvg -graphicssystem raster -qt-zlib -qt-libpng -qt-libmng -qt-libtiff -qt-libjpeg -no-dsp -no-vcproj -no-incredibuild-xge -plugin-manifests -process -mp -rtti -no-3dnow -mmx -sse -sse2 -openssl -no-dbus -no-phonon -no-phonon-backend -no-multimedia -no-audio-backend -no-webkit -no-script -no-scripttools -no-declarative -no-declarative-debug -no-style-s60 -no-style-windowsmobile -no-style-windowsce -no-style-cde -no-style-motif -qt-style-cleanlooks -qt-style-plastique -qt-style-windows -qt-style-windowsxp -qt-style-windowsvista -no-native-gestures -no-directwrite -qmake -nomake examples -nomake demos -nomake docs -I T:\install\OpenSSL\include -L T:\install\OpenSSL\lib -prefix T:\install\Qt nmake sub-src nmake sub-translations-make_default-ordered
-
Install Qt:
nmake install
-
Unpack qbittorrent into
\sources\qbt\
. -
Open
VS2013 x64 Native Tools Command Prompt
. -
Navigate to qbittorrent source folder.
-
Prepare qBt sources:
- Unpack Maxmind GeoIP.dat file into
.\src\geoip\
- Edit
.\src\src.pro
:- Find and remove line
DEFINES += BOOST_FILESYSTEM_VERSION=2
- Find and remove line
- Edit
winconf-msvc.pri
:-
Find
CONFIG(debug, debug|release) { LIBS += libtorrentd.lib \ libboost_system-vc90-mt-sgd-1_51.lib } else { LIBS += libtorrent.lib \ libboost_system-vc90-mt-s-1_51.lib }
and replace with
CONFIG(debug, debug|release) { LIBS += torrent.lib \ boost_system.lib } else { LIBS += torrent.lib \ boost_system.lib }
-
- Edit
winconf.pri
and adjust paths accordingly (remember thatT:\install\
is used as an example):-
Find
INCLUDEPATH += $$quote(C:/qBittorrent/boost_1_51_0)
and replace with
INCLUDEPATH += $$quote(T:/install/Boost/include)
-
Find
INCLUDEPATH += $$quote(C:/qBittorrent/RC_0_16/include)
and replace withINCLUDEPATH += $$quote(T:/install/libtorrent/include)
-
Find
INCLUDEPATH += $$quote(C:/qBittorrent/Zlib/include)
and replace withINCLUDEPATH += $$quote(T:/install/Zlib/include)
and insertINCLUDEPATH += $$quote(T:/install/OpenSSL/include)
on next line -
Find
LIBS += $$quote(-LC:/qBittorrent/boost_1_51_0/stage/lib)
and replace withLIBS += $$quote(-LT:/install/Boost/lib)
-
Find
LIBS += $$quote(-LC:/qBittorrent/RC_0_16/bin/<path-according-to-the-build-options-chosen>)
and replace withLIBS += $$quote(-LT:/install/libtorrent/lib)
-
Find
LIBS += $$quote(-LC:/qBittorrent/Zlib/lib)
and replace withLIBS += $$quote(-LT:/install/Zlib/lib)
and insertLIBS += $$quote(-LT:/install/OpenSSL/lib)
on next line -
Find and remove the following lines:
DEFINES += BOOST_ASIO_SEPARATE_COMPILATION
DEFINES += BOOST_SYSTEM_STATIC_LINK=1
-
Find
DEFINES += BOOST_ALL_NO_LIB
and insertDEFINES += BOOST_ASIO_ENABLE_CANCELIO
on next line -
Find
DEFINES += BOOST_EXCEPTION_DISABLE
and insertDEFINES += BOOST_ASIO_DYN_LINK DEFINES += BOOST_ALL_DYN_LINK
on previous line
-
Find
DEFINES += TORRENT_USE_OPENSSL
and insertDEFINES += TORRENT_LINKING_SHARED
on next line -
Find
DEFINES += _WIN32_WINNT=0x0500
and replace withDEFINES += _WIN32_WINNT=0x0600
- If you want to build For XP 64-bit or WinServer 2003 64-bit replace
DEFINES += _WIN32_WINNT=0x0500
withDEFINES += _WIN32_WINNT=0x0501
- If you want to build For XP 64-bit or WinServer 2003 64-bit replace
-
- Unpack Maxmind GeoIP.dat file into
-
Build qBt:
SET "PATH=T:\install\Qt\bin;%PATH%"
-
Update translations
CD .\src lupdate -no-obsolete ./src.pro CD ..\
-
Build
MD build CD build qmake -config release -r ../qbittorrent.pro "CONFIG += warn_off msvc_mp rtti ltcg mmx sse sse2" "CONFIG -= 3dnow" nmake
-
-
Install qBt:
XCOPY /Y /Q /I .\src\release\qbittorrent.exe T:\install\qBittorrent\ FOR %X IN (QtCore4.dll QtGui4.dll QtNetwork4.dll QtXml4.dll) DO ( COPY /Y T:\install\Qt\bin\%X T:\install\qBittorrent\ ) XCOPY /Y /Q /I T:\install\Qt\plugins\imageformats\qico4.dll T:\install\qBittorrent\plugins\imageformats\ FOR /F "usebackq" %X IN (`DIR /B "T:\sources\qbt\src\qt-translations\"`) DO ( IF EXIST "T:\install\Qt\translations\%X" ( COPY /Y "T:\install\Qt\translations\%X" "T:\sources\qbt\src\qt-translations\" ) ) XCOPY /Y /Q /I T:\sources\qbt\src\qt-translations\qt_* T:\install\qBittorrent\translations\ XCOPY /Y /Q /I T:\install\OpenSSL\bin\*.dll T:\install\qBittorrent\ XCOPY /Y /Q /I T:\install\libtorrent\lib\torrent.dll T:\install\qBittorrent\ XCOPY /Y /Q /I T:\install\Boost\lib\*.dll T:\install\qBittorrent\ echo [Paths] > T:\install\qBittorrent\qt.conf echo Translations = ./translations >> T:\install\qBittorrent\qt.conf echo Plugins = ./plugins >> T:\install\qBittorrent\qt.conf
If you want to use the resulting binaries on other Windows computers (or redistribute them) you will need Visual C++ Redistributable Packages for Visual Studio 2013 (x64). Users must have it installed in order to use any x86_64 software compiled with Visual Studio 2013. If you are using qBt on computer, which was used for building it, you don't need VC++ 2013 x64 Redistributable Package, because you already have it installed (it came with Visual Studio 2013).
Alternatively you can copy redistributable dlls into program folder like this:
XCOPY /Y /Q /I "%ProgramFiles(x86)%\Microsoft Visual Studio 12.0\VC\redist\x64\Microsoft.VC120.CRT\*.dll" T:\install\qBittorrent\