tdesktopgithub 上有介绍编译步骤:tdesktop-building-win-x64

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.
tdesktop-build-folder

按照官方文档把所需要的第三方软件安装到对应的位置

Download Strawberry Perl installer from http://strawberryperl.com/ and install to BuildPath\ThirdParty\Strawberry
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 3.9 installer from https://www.python.org/downloads/ and install to BuildPath\ThirdParty\Python39
Download CMake 3.21 or later 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
Download Git installer from https://git-scm.com/download/win and install it.
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:

Open Control Panel -> System -> Advanced system settings.
Press Environment Variables…
Select Path.
Press Edit.
Add BuildPath\ThirdParty\Python39 value.
Add BuildPath\ThirdParty\NuGet value.

所需要的第三方软件打包

tdesktop-build-tool

tdesktop最新的源码编译工具是使用vs2022,可以下载安装社区版
打开vs2022 x64命令行窗口
tdesktop-build-vs2022

Open x64 Native Tools Command Prompt for VS 2022.bat, go to BuildPath and run

1
python -m pip install pywin32

Clone source code and prepare libraries
Open x64 Native Tools Command Prompt for VS 2022.bat, go to BuildPath and run

1
2
git clone --recursive https://github.com/telegramdesktop/tdesktop.git
tdesktop\Telegram\build\prepare\win.bat

注意: 这里克隆子目录有可能会失败,可以到tdesktop-github-tree打开对应的仓库自行下载并切换到指定的提交

这里的每个库都要安装编译成功
tdesktop-build

如果没有梯子,可以通过修改prepare.py脚本解决
打开\BuildPath\tdesktop\Telegram\build\prepare\prepare.py把无法下载的仓库地址替换成github上对应的仓库
prepare-modify-for-git.py

1
configure.bat x64 -D TDESKTOP_API_ID=17349 -D TDESKTOP_API_HASH=344583e45741c457fe1862106095a5eb -D DESKTOP_APP_USE_PACKAGED=OFF -D DESKTOP_APP_DISABLE_CRASH_REPORTS=OFF

对应的 api 在这里 tdesktop-api_credentials

结果

tdesktop-sln
images/tdesktop-vs2022
tdesktop-result

为了更好的调试,可以在vs2022安装Qt Visual Studio Tools扩展
Qt Visual Studio Tools
For better debugging you may want to install Qt Visual Studio Tools:

Open Extensions -> Manage Extensions
Go to Online tab
Search for Qt
Install Qt Visual Studio Tools extension

问题

1.安装 MSYS2
msys2-updating-trust-database

2.安装Python
No python installation was detectedNo python installation was detected

3.vs-error-C2220
vs-error-C2220