Telegram之tdesktop源码编译
生活随笔
收集整理的這篇文章主要介紹了
Telegram之tdesktop源码编译
小編覺得挺不錯的,現在分享給大家,幫大家做個參考.
? ? 編譯第三方開源項目代碼實際上最坑爹的,因為開源,寫的幫助說明簡單的不能再簡單了,許多細節都是沒有的。
? ? 最近因為公司需要研究mtproto,所以需要編譯tdesktop,由于本人天資愚鈍,花了兩個星期才搞定,為了后來者可以少一些坑,將一些注意事項記錄下來。
? ? 第一步,安裝第三方庫
Download ActivePerl installer from https://www.activestate.com/activeperl/downloads and install to BuildPath\ThirdParty\Perl Download NASM installer from http://www.nasm.us and install to BuildPath\ThirdParty\NASM Download Yasm executable from http://yasm.tortall.net/Download.html, rename to yasm.exe and put to BuildPath\ThirdParty\yasm Download MSYS2 installer from http://www.msys2.org/ and install to BuildPath\ThirdParty\msys64 Download jom archive from http://download.qt.io/official_releases/jom/jom.zip and unpack to BuildPath\ThirdParty\jom Download Python 2.7 installer from https://www.python.org/downloads/ and install to BuildPath\ThirdParty\Python27 Download CMake installer from https://cmake.org/download/ and install to BuildPath\ThirdParty\cmake Download Ninja executable from https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-win.zip and unpack to BuildPath\ThirdParty\Ninja Open x86 Native Tools Command Prompt for VS 2017.bat, go to BuildPath and runcd ThirdParty git clone https://chromium.googlesource.com/external/gyp cd gyp git checkout a478c1ab51 cd ..\..注意點①:安裝python時需要勾選將python添加到環境變量path中
注意點②:添加環境變量
Add GYP and Ninja to your PATH:Open Control Panel -> System -> Advanced system settings Press Environment Variables... Select Path Press Edit Add BuildPath\ThirdParty\gyp value Add BuildPath\ThirdParty\Ninja value? ? 第二步:下載tdesktop源碼
--設置PATH環境變量(如果后面關閉命令行窗口,需要重新設置) SET PATH=%cd%\ThirdParty\Perl\bin;%cd%\ThirdParty\Python27;%cd%\ThirdParty\NASM;%cd%\ThirdParty\jom;%cd%\ThirdParty\cmake\bin;%cd%\ThirdParty\yasm;%PATH%git clone --recursive https://github.com/telegramdesktop/tdesktop.git? ? 第三步:安裝第三方庫
在此有點說明,推薦準備兩套環境,一套環境上只裝vs2017,一套環境上只裝vs2015,本人比較菜,兩套vs裝在一個服務器上老是編譯失敗
--使用vs2017git clone https://github.com/Microsoft/Range-V3-VS2015 range-v3git clone https://github.com/telegramdesktop/lzma.git cd lzma\C\Util\LzmaLib --打開當前目錄下的LzmaLib.vcxproj,重定解決方案目標(Debug和Release都需要) msbuild LzmaLib.sln /property:Configuration=Debug msbuild LzmaLib.sln /property:Configuration=Release cd ..\..\..\.. --使用vs2015git clone https://github.com/openssl/openssl.git cd openssl git checkout OpenSSL_1_0_1-stable perl Configure no-shared --prefix=%cd%\Release --openssldir=%cd%\Release VC-WIN32 ms\do_ms --ms命令只有vs2015才有 nmake -f ms\nt.mak nmake -f ms\nt.mak install xcopy tmp32\lib.pdb Release\lib\ nmake -f ms\nt.mak clean perl Configure no-shared --prefix=%cd%\Debug --openssldir=%cd%\Debug debug-VC-WIN32 --這一步是不需要從github上下載文件的,放心執行 ms\do_ms nmake -f ms\nt.mak nmake -f ms\nt.mak install xcopy tmp32.dbg\lib.pdb Debug\lib\ cd .. --使用vs2017git clone https://github.com/telegramdesktop/zlib.git cd zlib git checkout tdesktop cd contrib\vstudio\vc14 --打開當前目錄下的zlibstat.vcxproj,重定解決方案目標(Debug和Release都需要) msbuild zlibstat.vcxproj /property:Configuration=Debug msbuild zlibstat.vcxproj /property:Configuration=ReleaseWithoutAsm cd ..\..\..\..git clone git://repo.or.cz/openal-soft.git cd openal-soft git checkout 18bb46163af cd build cmake -G "Visual Studio 15 2017" -D LIBTYPE:STRING=STATIC -D FORCE_STATIC_VCRT:STRING=ON .. msbuild OpenAL32.vcxproj /property:Configuration=Debug msbuild OpenAL32.vcxproj /property:Configuration=Release cd ..\..git clone https://github.com/google/breakpad cd breakpad git checkout a1dbcdcb43 git apply ../../tdesktop/Telegram/Patches/breakpad.diff cd src git clone https://github.com/google/googletest testing cd client\windows set GYP_MSVS_VERSION=2017 gyp --no-circular-check breakpad_client.gyp --format=ninja cd ..\.. ninja -C out/Debug common crash_generation_client exception_handler ninja -C out/Release common crash_generation_client exception_handler cd ..\..
注意:如果編譯openal-soft失敗,可以嘗試需要修改openal-soft/目錄下的CMakeLists.txt文件
--使用vs2015 git clone https://github.com/telegramdesktop/opus.git cd opus git checkout tdesktop cd win32\VS2015 --打開當前目錄下的xxx.vcxproj,重定解決方案目標(Debug和Release都需要) --需要設置編譯平臺 msbuild opus.sln /property:Configuration=Debug /property:Platform="Win32" msbuild opus.sln /property:Configuration=Release /property:Platform="Win32"--ffmpeg安裝從這里開始,重裝的時候請注意 cd ..\..\..\.. SET PATH_BACKUP_=%PATH% SET PATH=%cd%\ThirdParty\msys64\usr\bin;%PATH% cd Librariesgit clone https://github.com/FFmpeg/FFmpeg.git ffmpeg cd ffmpeg git checkout release/3.4set CHERE_INVOKING=enabled_from_arguments set MSYS2_PATH_TYPE=inherit bash --login ../../tdesktop/Telegram/Patches/build_ffmpeg_win.sh SET PATH=%PATH_BACKUP_% cd ..git clone git://code.qt.io/qt/qt5.git qt5_6_2 cd qt5_6_2 perl init-repository --module-subset=qtbase,qtimageformats git checkout v5.6.2 cd qtimageformats git checkout v5.6.2 cd ..\qtbase git checkout v5.6.2 git apply ../../../tdesktop/Telegram/Patches/qtbase_5_6_2.diff cd ..configure -debug-and-release -force-debug-info -opensource -confirm-license -static -I "%cd%\..\openssl\Release\include" -no-opengl -openssl-linked OPENSSL_LIBS_DEBUG="%cd%\..\openssl\Debug\lib\ssleay32.lib %cd%\..\openssl\Debug\lib\libeay32.lib" OPENSSL_LIBS_RELEASE="%cd%\..\openssl\Release\lib\ssleay32.lib %cd%\..\openssl\Release\lib\libeay32.lib" -mp -nomake examples -nomake tests -platform win32-msvc2015jom -j4 jom -j4 install cd .. --使用vs2017cd ../tdesktop/Telegram gyp\refresh.bat--推薦使用vs2017 Build the projectBuild項目有可能提示: error C2220:警告被視為錯誤 - 沒有生成“object”文件
遇到這種問題是因為原因是該文件的代碼頁為英文,而我們系統中的代碼頁為中文。
解決方案是在源文件目錄下用vs新建一個空白文件,把源文件代碼粘貼過去,然后備份一下源文件,修改新文件名字和源文件名字一致,再次進行編譯,可以編譯通過。
總結
以上是生活随笔為你收集整理的Telegram之tdesktop源码编译的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 安卓、苹果手机数据转移时的备份以及恢复
- 下一篇: 885n虚拟服务器,TP-Link TL