编译第三方开源项目代码实际上最坑爹的,因为开源,写的帮助说明简单的不能再简单了,许多细节都是没有的。

最近因为公司需要研究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 project

Build项目有可能提示: error C2220:警告被视为错误 - 没有生成“object”文件

遇到这种问题是因为原因是该文件的代码页为英文,而我们系统中的代码页为中文。

解决方案是在源文件目录下用vs新建一个空白文件,把源文件代码粘贴过去,然后备份一下源文件,修改新文件名字和源文件名字一致,再次进行编译,可以编译通过。

Telegram之tdesktop源码编译相关推荐

  1. java调用clang编译的so_写Java这么久,JDK源码编译过没?编译JDK源码踩坑纪实

    好奇害死羊 很多小伙伴们做Java开发,天天写Java代码,肯定离不开Java基础环境:JDK,毕竟我们写好的Java代码也是跑在JVM虚拟机上. 一般来说,我们学Java之前,第一步就是安装JDK环 ...

  2. 5单个编译总会编译全部_玩转Android10(五)源码编译开发中常用命令

    源码开发编译中,熟练掌握常用命令,可以提高开发工作效率.Android源码中,将相关的命令分为如下几类: 1.初始化源码编译环境 初始化编译环境,为后续提供如lunch.make.xxgrep.god ...

  3. mono和monodevelop源码编译安装

    之所以用源码编译的方式安装mono和monodevelop,是因为通过yum安装的mono不是最新版本,而且monodevelop不能建 asp.net MVC3的工程. 而且通过源码安装,可以进一步 ...

  4. nginx源码编译、负载均衡及模块的扩展

    1.nginx源码编译 实验环境: iptables和selinux关闭 redhat6.5 nginx:test1: 172.25.1.11 [root@test1 ~]# ls nginx-1.1 ...

  5. mac通过tree源码编译安装tree

    通过tree源码编译安装  下载源码:curl -O ftp://mama.indstate.edu/linux/tree/tree-1.6.0.tgz  解压源码:tar xzvf tree-1.6 ...

  6. 干货|TensorFlow开发环境搭建(Ubuntu16.04+GPU+TensorFlow源码编译)

    点击上方"小白学视觉",选择加"星标"或"置顶" 重磅干货,第一时间送达 本文转自|机器学习算法工程师 安装平台 1 平台 目前Tensor ...

  7. Nginx 源码编译安装

    Nginx 源码编译安装环境 Centos7 Nginx1.8.1    下载地址:http://nginx.org/download/ 选择自己想要的版本 我这边使用1.8.1,下载地址:http: ...

  8. 基本lnmp平台的搭建(源码编译)

    lnmp :linux ,nginx ,mysql ,php 系统环境:rhel6.0    selinux and iptables disabled  (这里我们都只用源码编译的方式) 1 ste ...

  9. 源码编译安装percona-xtrabackup-2.3.2

    一.系统包需求 rpm -q libaio-devel libgpg-error-devel libgcrypt-devel autoconf automake libidn-devel libcur ...

最新文章

  1. Python之父考虑重构Python解释器
  2. C# CheckBox与RadioButton
  3. linux之安装frida遇到的问题
  4. Android中级之网络数据解析一之Json解析
  5. 一文搞懂物联网Modbus通讯协议
  6. python语言运算符有三种_《Python语言程序设计》 —2.3 运算符
  7. jQuery:从零开始,DIY一个jQuery(1)
  8. 五大软件设计原则学习笔记4——接口隔离原则
  9. findpeaks 寻找峰值函数
  10. ODBC连接达梦数据库配置
  11. springboot整合阿里云OSS存储(对象存储)图文详解-———入门操作指南。
  12. 利用Arthas进行简单的故障注入
  13. 有哪些比较好的国外知名广告联盟平台?
  14. 好玩的数据结构与算法——八皇后游戏(回溯)
  15. 北京二手房价预测(数据分析)
  16. Lync 2010升级到Lync 2013 之设定企业联盟!
  17. Excel散点图 如何用平滑线 连接 不连续的点
  18. 没有几样强迫症,不配自称程序员
  19. webstorm最新激活方法。绝对有效
  20. 使用vue做一个“淘宝“项目——3

热门文章

  1. STC89C52RC的寄存器
  2. 【Python Brain】SNN脉冲神经网络开源模拟器 The Brian Simulator 仿真指南
  3. 计算机作文英语初中,初中书面表达的英语作文(精选5篇)
  4. 使用 Python (Pyxel)制作一个经典的 Lode Runner 游戏
  5. 大学生网页设计HTML理论介绍及常用格式
  6. 在奥维中如何加载星图地球数据云的地图?
  7. 中国人民大学信息学院79级同学聚会感言
  8. APK安装失败的原因之一
  9. 2021-2025年中国彩色多普勒超声诊断仪行业市场供需与战略研究报告
  10. wamp+cmd命令行配置zend框架