2016-07-03 13:17:22 +00:00
# Build instructions for Visual Studio 2015
2017-02-16 10:57:53 +00:00
- [Prepare folder ](#prepare-folder )
- [Clone source code ](#clone-source-code )
- [Prepare libraries ](#prepare-libraries )
* [OpenSSL ](#openssl )
* [LZMA SDK 9.20 ](#lzma-sdk-920 )
+ [Building library ](#building-library )
* [zlib 1.2.8 ](#zlib-128 )
+ [Building library ](#building-library-1 )
* [libexif 0.6.20 ](#libexif-0620 )
+ [Building library ](#building-library-2 )
* [OpenAL Soft, slightly patched ](#openal-soft-slightly-patched )
+ [Building library ](#building-library-3 )
* [Opus codec ](#opus-codec )
+ [Building libraries ](#building-libraries )
* [FFmpeg ](#ffmpeg )
+ [Building libraries ](#building-libraries-1 )
* [Qt 5.6.2, slightly patched ](#qt-562-slightly-patched )
+ [Apply the patch ](#apply-the-patch )
+ [Install Windows SDKs ](#install-windows-sdks )
+ [Building library ](#building-library-4 )
* [Qt5Package ](#qt5package )
* [Google Breakpad ](#google-breakpad )
+ [Installation ](#installation )
- [depot_tools ](#depot_tools )
- [Breakpad ](#breakpad )
+ [Build ](#build )
- [Building Telegram Desktop ](#building-telegram-desktop )
+ [Setup GYP/Ninja and generate VS solution ](#setup-gypninja-and-generate-vs-solution )
+ [Configure VS ](#configure-vs )
+ [Build the project ](#build-the-project )
2016-07-03 13:17:22 +00:00
## Prepare folder
2014-06-25 20:15:34 +00:00
2016-10-11 09:56:51 +00:00
Choose a folder for the future build, for example **D:\\TBuild\\** . There you will have two folders, **Libraries** for third-party libs and **tdesktop** for the app.
All commands (if not stated otherwise) will be launched from **VS2015 x86 Native Tools Command Prompt.bat** (should be in **Start Menu > Programs > Visual Studio 2015** menu folder).
2014-06-25 20:15:34 +00:00
2016-07-03 13:17:22 +00:00
## Clone source code
2014-06-25 20:15:34 +00:00
2016-10-11 09:56:51 +00:00
Go to **D:\\TBuild**
2014-06-25 20:15:34 +00:00
2016-10-11 09:56:51 +00:00
D:
cd TBuild
2014-06-25 20:15:34 +00:00
2016-10-11 09:56:51 +00:00
and run
2017-03-10 11:22:23 +00:00
git clone --recursive https://github.com/telegramdesktop/tdesktop.git
2016-10-11 09:56:51 +00:00
mkdir Libraries
2014-06-25 20:15:34 +00:00
2016-07-03 13:17:22 +00:00
## Prepare libraries
2014-06-25 20:15:34 +00:00
2016-07-03 13:17:22 +00:00
### OpenSSL
2015-10-19 21:24:39 +00:00
2016-10-11 09:56:51 +00:00
Go to **D:\\TBuild\\Libraries** and run
2015-10-19 21:24:39 +00:00
git clone https://github.com/openssl/openssl.git
cd openssl
git checkout OpenSSL_1_0_1-stable
perl Configure VC-WIN32 --prefix=D:\TBuild\Libraries\openssl\Release
ms\do_ms
nmake -f ms\nt.mak
nmake -f ms\nt.mak install
cd ..
git clone https://github.com/openssl/openssl.git openssl_debug
cd openssl_debug
git checkout OpenSSL_1_0_1-stable
perl Configure debug-VC-WIN32 --prefix=D:\TBuild\Libraries\openssl_debug\Debug
ms\do_ms
nmake -f ms\nt.mak
nmake -f ms\nt.mak install
2014-06-25 20:15:34 +00:00
2016-07-03 13:17:22 +00:00
### LZMA SDK 9.20
2014-06-25 20:15:34 +00:00
http://www.7-zip.org/sdk.html > Download [**LZMA SDK (C, C++, C#, Java)** 9.20 ](http://downloads.sourceforge.net/sevenzip/lzma920.tar.bz2 )
2016-10-11 09:56:51 +00:00
Extract to **D:\\TBuild\\Libraries**
2014-06-25 20:15:34 +00:00
2016-07-03 13:17:22 +00:00
#### Building library
2014-06-25 20:15:34 +00:00
2016-10-11 09:56:51 +00:00
* Open in VS2015 **D:\\TBuild\\Libraries\\lzma\\C\\Util\\LzmaLib\\LzmaLib.dsw** > One-way upgrade – **OK**
2014-06-25 20:15:34 +00:00
* For **Debug** and **Release** configurations
2016-05-19 11:29:06 +00:00
* LzmaLib Properties > General > Configuration Type = **Static library (.lib)** – **Apply**
2014-06-25 20:15:34 +00:00
* LzmaLib Properties > Librarian > General > Target Machine = **MachineX86 (/MACHINE:X86)** – **OK**
2016-05-19 11:29:06 +00:00
* If you can't find **Librarian** , you forgot to click **Apply** after changing the Configuration Type.
* For **Debug** configuration
* LzmaLib Properties > C/C++ > General > Debug Information Format = **Program Database (/Zi)** - **OK**
2014-06-25 20:15:34 +00:00
* Build Debug configuration
* Build Release configuration
2016-07-03 13:17:22 +00:00
### zlib 1.2.8
2014-06-25 20:15:34 +00:00
2017-02-16 09:35:50 +00:00
http://www.zlib.net/fossils/ > Download [zlib-1.2.8.tar.gz ](http://www.zlib.net/fossils/zlib-1.2.8.tar.gz )
2014-06-25 20:15:34 +00:00
2016-10-11 09:56:51 +00:00
Extract to **D:\\TBuild\\Libraries**
2014-06-25 20:15:34 +00:00
2016-07-03 13:17:22 +00:00
#### Building library
2014-06-25 20:15:34 +00:00
2016-10-11 09:56:51 +00:00
* Open in VS2015 **D:\\TBuild\\Libraries\\zlib-1.2.8\\contrib\\vstudio\\vc11\\zlibvc.sln** > One-way upgrade – **OK**
2014-06-25 20:15:34 +00:00
* We are interested only in **zlibstat** project, but it depends on some custom pre-build step, so build all
* For **Debug** configuration
* zlibstat Properties > C/C++ > Code Generation > Runtime Library = **Multi-threaded Debug (/MTd)** – **OK**
* For **Release** configuration
* zlibstat Properties > C/C++ > Code Generation > Runtime Library = **Multi-threaded (/MT)** – **OK**
* Build Solution for Debug configuration – only **zlibstat** project builds successfully
* Build Solution for Release configuration – only **zlibstat** project builds successfully
2016-07-03 13:17:22 +00:00
### libexif 0.6.20
2014-06-25 20:15:34 +00:00
2016-10-11 09:56:51 +00:00
Go to **D:\\TBuild\\Libraries** and run
2014-06-25 20:15:34 +00:00
git clone https://github.com/telegramdesktop/libexif-0.6.20.git
2016-07-03 13:17:22 +00:00
#### Building library
2014-06-25 20:15:34 +00:00
2016-10-11 09:56:51 +00:00
* Open in VS2015 **D:\\TBuild\\Libraries\\libexif-0.6.20\\win32\\lib_exif.sln**
2014-06-25 20:15:34 +00:00
* Build Debug configuration
* Build Release configuration
2016-07-03 13:17:22 +00:00
### OpenAL Soft, slightly patched
2014-09-04 07:33:44 +00:00
2016-10-11 09:56:51 +00:00
Go to **D:\\TBuild\\Libraries** and run
2014-09-04 07:33:44 +00:00
git clone git://repo.or.cz/openal-soft.git
2016-04-26 15:26:18 +00:00
cd openal-soft
2017-01-07 11:55:05 +00:00
git checkout 18bb46163af
2016-04-23 11:50:28 +00:00
git apply ./../../tdesktop/Telegram/Patches/openal.diff
2015-06-03 18:13:01 +00:00
2016-07-03 13:17:22 +00:00
#### Building library
2014-09-04 07:33:44 +00:00
* Install [CMake ](http://www.cmake.org/ )
2016-10-11 09:56:51 +00:00
* Go to **D:\\TBuild\\Libraries\\openal-soft\\build** and run
2015-10-25 17:08:45 +00:00
2016-10-17 20:20:30 +00:00
<!-- -->
2016-10-11 09:56:51 +00:00
cmake -G "Visual Studio 14 2015" -D LIBTYPE:STRING=STATIC -D FORCE_STATIC_VCRT:STRING=ON ..
2015-10-25 17:08:45 +00:00
2016-10-11 09:56:51 +00:00
* Open in VS2015 **D:\\TBuild\\Libraries\\openal-soft\\build\\OpenAL.sln** and build Debug and Release configurations
2014-09-04 07:33:44 +00:00
2016-07-03 13:17:22 +00:00
### Opus codec
2014-09-04 07:33:44 +00:00
2016-10-11 09:56:51 +00:00
Go to **D:\\TBuild\\Libraries** and run
2014-09-04 07:33:44 +00:00
2015-06-01 12:44:10 +00:00
git clone https://github.com/telegramdesktop/opus.git
2016-07-03 13:17:22 +00:00
#### Building libraries
2015-06-01 12:44:10 +00:00
2016-10-11 09:56:51 +00:00
* Open in VS2015 **D:\\TBuild\\Libraries\\opus\\win32\\VS2010\\opus.sln**
2014-09-04 07:33:44 +00:00
* Build Debug configuration
2015-06-01 12:44:10 +00:00
* Build Release configuration (it will be required in **FFmpeg** build!)
2014-09-04 07:33:44 +00:00
2016-07-03 13:17:22 +00:00
### FFmpeg
2014-09-04 07:33:44 +00:00
2016-10-11 09:56:51 +00:00
Go to **D:\\TBuild\\Libraries** and run
2014-09-04 07:33:44 +00:00
2015-10-19 21:24:39 +00:00
git clone https://github.com/FFmpeg/FFmpeg.git ffmpeg
cd ffmpeg
2017-01-05 09:08:16 +00:00
git checkout release/3.2
2014-09-04 07:33:44 +00:00
2015-06-01 12:44:10 +00:00
http://msys2.github.io/ > Download [msys2-x86_64-20150512.exe ](http://sourceforge.net/projects/msys2/files/Base/x86_64/msys2-x86_64-20150512.exe/download ) and install to **D:\\msys64**
2014-09-04 07:33:44 +00:00
2016-07-03 13:17:22 +00:00
#### Building libraries
2014-09-04 07:33:44 +00:00
2015-10-19 21:24:39 +00:00
Download [yasm for Win64 ](http://www.tortall.net/projects/yasm/releases/yasm-1.3.0-win64.exe ) from http://yasm.tortall.net/Download.html, rename **yasm-1.3.0-win64.exe** to **yasm.exe** and place it to your Visual C++ **bin** directory, like ** \\Program Files (x86)\\Microsoft Visual Studio 14\\VC\\bin\\**
2015-06-01 20:24:09 +00:00
2016-12-31 09:39:48 +00:00
While still running the VS2015 x86 Native Tools Command Prompt, go to **D:\\msys64** and launch **msys2_shell.bat** . There run
2015-06-01 12:44:10 +00:00
2015-10-19 21:24:39 +00:00
PATH="/c/Program Files (x86)/Microsoft Visual Studio 14.0/VC/BIN:$PATH"
2015-06-01 12:49:53 +00:00
2015-10-19 21:24:39 +00:00
cd /d/TBuild/Libraries/ffmpeg
2015-10-13 06:52:11 +00:00
pacman -Sy
2015-06-01 12:52:44 +00:00
pacman -S msys/make
pacman -S mingw64/mingw-w64-x86_64-opus
2015-10-14 11:30:59 +00:00
pacman -S diffutils
2015-06-01 20:40:09 +00:00
pacman -S pkg-config
2015-06-01 12:49:53 +00:00
2015-06-01 20:24:09 +00:00
PKG_CONFIG_PATH="/mingw64/lib/pkgconfig:$PKG_CONFIG_PATH"
2016-07-22 15:01:24 +00:00
./configure --toolchain=msvc --disable-programs --disable-doc --disable-everything --enable-protocol=file --enable-libopus --enable-decoder=aac --enable-decoder=aac_latm --enable-decoder=aasc --enable-decoder=flac --enable-decoder=gif --enable-decoder=h264 --enable-decoder=mp1 --enable-decoder=mp1float --enable-decoder=mp2 --enable-decoder=mp2float --enable-decoder=mp3 --enable-decoder=mp3adu --enable-decoder=mp3adufloat --enable-decoder=mp3float --enable-decoder=mp3on4 --enable-decoder=mp3on4float --enable-decoder=mpeg4 --enable-decoder=msmpeg4v2 --enable-decoder=msmpeg4v3 --enable-decoder=wavpack --enable-decoder=opus --enable-decoder=vorbis --enable-decoder=wmalossless --enable-decoder=wmapro --enable-decoder=wmav1 --enable-decoder=wmav2 --enable-decoder=wmavoice --enable-encoder=libopus --enable-hwaccel=h264_d3d11va --enable-hwaccel=h264_dxva2 --enable-parser=aac --enable-parser=aac_latm --enable-parser=flac --enable-parser=h264 --enable-parser=mpeg4video --enable-parser=mpegaudio --enable-parser=opus --enable-parser=vorbis --enable-demuxer=aac --enable-demuxer=flac --enable-demuxer=gif --enable-demuxer=h264 --enable-demuxer=mov --enable-demuxer=mp3 --enable-demuxer=ogg --enable-demuxer=wav --enable-muxer=ogg --enable-muxer=opus --extra-ldflags="-libpath:/d/TBuild/Libraries/opus/win32/VS2010/Win32/Release celt.lib silk_common.lib silk_float.lib"
2015-06-01 12:49:53 +00:00
2015-06-01 12:52:44 +00:00
make
make install
2014-09-04 07:33:44 +00:00
2016-10-17 21:33:24 +00:00
### Qt 5.6.2, slightly patched
2014-06-25 20:15:34 +00:00
* Install Python 3.3.2 from https://www.python.org/download/releases/3.3.2 > [**Windows x86 MSI Installer (3.3.2)** ](https://www.python.org/ftp/python/3.3.2/python-3.3.2.msi )
2016-10-11 09:56:51 +00:00
* Go to **D:\\TBuild\\Libraries** and run
2014-06-25 20:15:34 +00:00
2016-10-17 20:20:30 +00:00
<!-- -->
2016-10-17 21:33:24 +00:00
git clone git://code.qt.io/qt/qt5.git qt5_6_2
cd qt5_6_2
2016-04-23 11:40:42 +00:00
git checkout 5.6
2015-10-19 21:24:39 +00:00
perl init-repository --module-subset=qtbase,qtimageformats
2016-10-17 21:33:24 +00:00
git checkout v5.6.2
cd qtimageformats & & git checkout v5.6.2 & & cd ..
cd qtbase & & git checkout v5.6.2 & & cd ..
2014-06-25 20:15:34 +00:00
2016-07-03 13:17:22 +00:00
#### Apply the patch
2014-06-25 20:15:34 +00:00
2016-10-17 21:33:24 +00:00
cd qtbase & & git apply ../../../tdesktop/Telegram/Patches/qtbase_5_6_2.diff & & cd ..
2015-12-17 17:31:28 +00:00
2016-07-03 13:17:22 +00:00
#### Install Windows SDKs
2015-11-13 08:11:39 +00:00
2015-11-13 09:06:53 +00:00
If you didn't install Windows SDKs before, you need to install them now. To install the SDKs just open Telegram solution at **D:\TBuild\tdesktop\Telegram.sln** and on startup Visual Studio 2015 will popup dialog box and ask to download and install extra components (including Windows 7 SDK).
2015-11-13 08:11:39 +00:00
2015-11-13 09:06:53 +00:00
If you already have Windows SDKs then find the library folder and correct it at configure's command below (like **C:\Program Files (x86)\Windows Kits\8.0\Lib\win8\um\x86** ).
2015-10-19 21:24:39 +00:00
2016-07-03 13:17:22 +00:00
#### Building library
2016-08-07 08:36:14 +00:00
2016-12-31 09:39:48 +00:00
Go to **D:\\TBuild\\Libraries\\qt5_6_2** and run
2014-06-25 20:15:34 +00:00
2016-03-21 18:41:39 +00:00
configure -debug-and-release -force-debug-info -opensource -confirm-license -static -I "D:\TBuild\Libraries\openssl\Release\include" -L "C:\Program Files (x86)\Microsoft SDKs\Windows\v7.1A\Lib" -l Gdi32 -no-opengl -openssl-linked OPENSSL_LIBS_DEBUG="D:\TBuild\Libraries\openssl_debug\Debug\lib\ssleay32.lib D:\TBuild\Libraries\openssl_debug\Debug\lib\libeay32.lib" OPENSSL_LIBS_RELEASE="D:\TBuild\Libraries\openssl\Release\lib\ssleay32.lib D:\TBuild\Libraries\openssl\Release\lib\libeay32.lib" -mp -nomake examples -nomake tests -platform win32-msvc2015
2015-10-19 21:24:39 +00:00
nmake
nmake install
2014-06-25 20:15:34 +00:00
building (**nmake** command) will take really long time.
2016-07-03 13:17:22 +00:00
### Qt5Package
2014-06-25 20:15:34 +00:00
2015-10-19 21:24:39 +00:00
https://visualstudiogallery.msdn.microsoft.com/c89ff880-8509-47a4-a262-e4fa07168408
2014-06-25 20:15:34 +00:00
2015-10-19 21:24:39 +00:00
Download, close all VS2015 instances and install for VS2015
2014-06-25 20:15:34 +00:00
2016-07-03 13:17:22 +00:00
### Google Breakpad
Breakpad is a set of client and server components which implement a crash-reporting system.
2017-02-16 10:57:53 +00:00
#### Installation
2016-02-08 12:32:17 +00:00
2017-02-16 10:57:53 +00:00
##### depot_tools
2016-02-08 12:32:17 +00:00
2017-02-16 10:57:53 +00:00
Go to `D:\TBuild\Libraries` and run
2016-10-17 20:20:30 +00:00
2016-05-19 11:29:06 +00:00
git clone https://chromium.googlesource.com/chromium/tools/depot_tools.git
cd depot_tools
2017-02-16 10:57:53 +00:00
gclient
If you get errors like
Cannot rebase: You have unstaged changes.
Please commit or stash them.
Failed to update depot_tools.
run `git reset --hard HEAD` and execute `gclient` again
##### Breakpad
2016-05-19 11:29:06 +00:00
cd ..
2017-02-16 10:57:53 +00:00
mkdir breakpad & & cd breakpad
2016-05-19 11:29:06 +00:00
..\depot_tools\fetch breakpad
..\depot_tools\gclient sync
2016-07-03 13:17:22 +00:00
xcopy src\src\* src /s /i
2017-02-17 12:28:29 +00:00
rmdir src\src /s /q
2016-05-19 11:29:06 +00:00
2016-07-03 13:17:22 +00:00
#### Build
2016-02-08 12:32:17 +00:00
2017-02-16 10:57:53 +00:00
* Open `D:\TBuild\Libraries\breakpad\src\client\windows\breakpad_client.sln` in VS2015
* Change `Treat WChar_t As Built in Type` to `No` in all projects & configurations (should be in Project -> Properties -> C/C++ -> Language)
* Change `Treat Warnings As Errors` to `No` in all projects & configurations (should be in Project -> Properties -> C/C++ -> General)
2016-02-08 12:32:17 +00:00
* Build Debug configuration
* Build Release configuration
2016-07-03 13:17:22 +00:00
## Building Telegram Desktop
2014-06-25 20:15:34 +00:00
2016-08-14 18:41:31 +00:00
#### Setup GYP/Ninja and generate VS solution
* Download [Ninja binaries ](https://github.com/ninja-build/ninja/releases/download/v1.7.1/ninja-win.zip ) and unpack them to **D:\\TBuild\\Libraries\\ninja** to have **D:\\TBuild\\Libraries\\ninja\\ninja.exe**
2016-10-11 09:56:51 +00:00
* Go to **D:\\TBuild\\Libraries** and run
2016-08-14 18:41:31 +00:00
2016-10-17 20:20:30 +00:00
<!-- -->
2016-08-14 18:41:31 +00:00
git clone https://chromium.googlesource.com/external/gyp
SET PATH=%PATH%;D:\TBuild\Libraries\gyp;D:\TBuild\Libraries\ninja;
cd ..\tdesktop\Telegram
2017-02-18 19:23:50 +00:00
2017-02-19 08:29:08 +00:00
If you want to pass a build define (like `TDESKTOP_DISABLE_AUTOUPDATE` or `TDESKTOP_DISABLE_NETWORK_PROXY` ), call `set TDESKTOP_BUILD_DEFINES=TDESKTOP_DISABLE_AUTOUPDATE,TDESKTOP_DISABLE_NETWORK_PROXY,...` (comma seperated string)
2017-02-18 19:23:50 +00:00
After, call `gyp\refresh.bat`
2016-08-14 18:41:31 +00:00
#### Configure VS
2015-10-19 21:24:39 +00:00
* Launch VS2015 for configuring Qt5Package
2014-06-25 20:15:34 +00:00
* QT5 > Qt Options > Add
2016-10-17 21:33:24 +00:00
* Version name: **Qt 5.6.22Win32**
* Path: **D:\TBuild\Libraries\qt5_6_2\qtbase**
* Default Qt/Win version: **Qt 5.6.2 Win32** – **OK** - You may need to restart Visual Studio for this to take effect.
2016-08-14 18:41:31 +00:00
#### Build the project
2014-06-25 20:15:34 +00:00
* File > Open > Project/Solution > **D:\TBuild\tdesktop\Telegram.sln**
2016-08-14 18:41:31 +00:00
* Select Telegram project and press Build > Build Telegram (Debug and Release configurations)
* The result Telegram.exe will be located in **D:\TBuild\tdesktop\out\Debug** (and **Release** )