当前位置:网站首页>使用VS2022编译Telegram桌面端(tdesktop)
使用VS2022编译Telegram桌面端(tdesktop)
2022-06-25 22:31:00 【草上爬】
2018年的时候参考Telegram桌面端(tdesktop)编译方法成功编译过tdesktop,后来比较忙,就没管它了
这段时间正好在研究IM,就把当年的Telegram工程找出来,依然能正常编译,但是无法登录了,提示需要升级
为了调试方便,只能参考官编译方指导用最新的源码再编译一遍,编译工具已经换成了VS2022,可以确定的是,参考官方编译指导可以编译成功(前提是能科学上网)
因为工作用得是VS2017,so,为了稳妥起见,还是在虚拟机里试试VS2022吧
在VMware Workstation 16 Pro里安装Windows 10有个地方要注意,在创建虚拟机时不要指定ISO映像文件,等虚拟机创建完成后,需要在“虚拟机设置”的“选项”页里“固件类型”中选择“BIOS”,然后再加载ISO映像,否则ISO映像无法识别

一.编译
Prepare folder
The build is done in Visual Studio 2022 with 10.0.22000.0 SDK version.
注释:安装的VS2012的时候选择10.0.22000.0 SDK
Choose an empty folder for the future build, for example D:\TBuild. It will be named BuildPath in the rest of this document. Create two folders there, BuildPath\ThirdParty and BuildPath\Libraries.
All commands (if not stated otherwise) will be launched from x86 Native Tools Command Prompt for VS 2022.bat (should be in Start Menu > Visual Studio 2022 menu folder). Pay attention not to use any other Command Prompt.
Install third party software
1.Download Strawberry Perl installer from http://strawberryperl.com/ and install to BuildPath\ThirdParty\Strawberry
2.Download NASM installer from http://www.nasm.us and install to BuildPath\ThirdParty\NASM
3.Download Yasm executable from http://yasm.tortall.net/Download.html, rename to yasm.exe and put to BuildPath\ThirdParty\yasm
4.Download MSYS2 installer from http://www.msys2.org/ and install to BuildPath\ThirdParty\msys64
5.Download jom archive from http://download.qt.io/official_releases/jom/jom.zip and unpack to BuildPath\ThirdParty\jom
6.Download Python 3.9 installer from https://www.python.org/downloads/ and install to BuildPath\ThirdParty\Python39
7.Download CMake 3.21 or later installer from https://cmake.org/download/ and install to BuildPath\ThirdParty\cmake
8.Download Ninja executable from https://github.com/ninja-build/ninja/releases/download/v1.7.2/ninja-win.zip and unpack to BuildPath\ThirdParty\Ninja
9.Download Git installer from https://git-scm.com/download/win and install it.
10.Download NuGet executable from https://dist.nuget.org/win-x86-commandline/latest/nuget.exe and put to BuildPath\ThirdParty\NuGet
Add Python 3.9 and NuGet to your PATH:
1.Open Control Panel -> System -> Advanced system settings.
2.Press Environment Variables....
3.Select Path.
4.Press Edit.
5.Add BuildPath\ThirdParty\Python39 value.
6.Add BuildPath\ThirdParty\NuGet value.
Open x86 Native Tools Command Prompt for VS 2022.bat, go to BuildPath and run
注释:我编译的是32位,所以打开的是 x86 Native Tools Command Prompt for VS 2022.bat
python -m pip install pywin32
注释:安装python的时一定要勾选pip
Clone source code and prepare libraries
Open x86 Native Tools Command Prompt for VS 2022.bat, go to BuildPath and run
git clone --recursive https://github.com/telegramdesktop/tdesktop.git
注释:这时如果你发现网速慢,不要在github上直接下载源码,再解压。因为它是一个递归clone。--recursive,除了telegram以外,它会clone一些telegram以外的仓库,即子仓库。
实操过程中,clone子创库时会出现443 timeout错误,此时需要用命令行设置代理(设置到环境变量中也行)
git config --global http.proxy http://127.0.0.1:7890
git config --global https.proxy https://127.0.0.1:7890
这里的端口号7890需根据自己的科学上网工具修改
印象中还有个OpenSSL SSL_read: Connection was reset, errno 10054的错误,参考下列文章一顿操作猛如虎,也不知是哪条指令起了作用
https://blog.csdn.net/m0_51269961/article/details/123709195
继续拉取子模块:git submodule update
tdesktop\Telegram\build\prepare\win.bat
Build the project
Go to BuildPath\tdesktop\Telegram and run
configure.bat -D TDESKTOP_API_ID=YOUR_API_ID -D TDESKTOP_API_HASH=YOUR_API_HASH -D DESKTOP_APP_USE_PACKAGED=OFF -D DESKTOP_APP_DISABLE_CRASH_REPORTS=OFF
注释:这里的YOUR_API_ID和YOUR_API_HASH 要替换成自己的api id和api hash,通过https://my.telegram.org/auth获取,手机号前要加+86

如果自己不是调用Telegram API来开发第三方应用,只是想测试玩玩,可以用官方提供的测试api id和api hash。
api_id: 17349
api_hash: 344583e45741c457fe1862106095a5eb
服务器对该测试api id和api hash用很多限制,但是实测自己的桌面端给移动端发消息没问题,上面的指令变为(我用得就是这个)
configure.bat -D TDESKTOP_API_ID=17349 -D TDESKTOP_API_HASH=344583e45741c457fe1862106095a5eb -D DESKTOP_APP_USE_PACKAGED=OFF -D DESKTOP_APP_DISABLE_CRASH_REPORTS=OFFOpen BuildPath\tdesktop\out\Telegram.sln in Visual Studio 2022
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)
二.运行
最新的telegram桌面端得用移动端扫码登录,类似微信。移动端注册很方便,当然前提也是能科学上网。下图是二维码界面,详细说明了如何用移动端telegram扫码。

如果桌面端登录不上,可以设置代理后再试试,点击右上角“SETTINGS”,在弹窗中选择“use custom proxy”


代理设置成功后,左下角的小盾牌会点亮,该小盾牌是与服务器的连接状态


原文链接:https://blog.csdn.net/caoshangpa/article/details/125382685
边栏推荐
- Solution to component stele in SMT chip processing
- Summary of common terms and knowledge in SMT chip processing industry
- 毕业季 | 在不断探索中拟合最好的自己
- Explanation of chip processing manufacturer__ What is ICT? What is the main test? Advantages and disadvantages of ICT testing?
- Cloud rendering and Intel jointly create the "core" era of cloud rendering
- 性能领跑云原生数据库市场!英特尔携腾讯共建云上技术生态
- 机器视觉:照亮“智”造新“视”界
- Redux workflow explanation + small examples
- Oracle RAC cluster failed to start
- [OEM special event] in the summer of "core cleaning", there are prize papers
猜你喜欢

The development context of Ba Kong Yuan universe industry

Redis jump table

元宇宙中的法律与自我监管

【图像检测】基于高斯过程和Radon变换实现血管跟踪和直径估计附matlab代码

Mysql5.7.31 user defined installation details

Daily question brushing record (IV)

Machine vision: illuminating "intelligence" and creating a new "vision" world

"Seamless" deployment of paddlenlp model based on openvinotm development kit

基于OpenVINOTM开发套件“无缝”部署PaddleNLP模型

How to deliver a shelter hospital within 48 hours?
随机推荐
把控元宇宙产业的发展脉络
Xiaohongshu microservice framework and governance and other cloud native business architecture evolution cases
Camkiia et gcamp6f sont - ils les mêmes?
Is camkiia the same as gcamp6f?
After being trapped by the sequelae of the new crown for 15 months, Stanford Xueba was forced to miss the graduation ceremony. Now he still needs to stay in bed for 16 hours every day: I should have e
Redis cluster
Cloud rendering and Intel jointly create the "core" era of cloud rendering
SMT贴片加工PCBA板清洗注意事项
Maintenance and key points of SMT Mounter
EBS R12.2.0升级到R12.2.6
Redis memory elimination mechanism
Smt贴片机保养与维护要点
dbca静默安装及建库
11.1.2 overview of Flink_ Wordcount case
Explanation of chip processing manufacturer__ What is ICT? What is the main test? Advantages and disadvantages of ICT testing?
Solution to component stele in SMT chip processing
Explain from a process perspective what happens to the browser after entering a URL?
ffmpeg 版本切换
鼠标拖拽围绕某个物体旋转展示
anchor free dection简介