TDLib

TDLib UWP development guide

Build a Universal Windows Platform SDK, Visual Studio extension or NuGet package and run the C# example.

GetTGAPI editorial teamUpdated
TDLib documentationReviewed

Source revision a94b83d67ab4 · TDLib contributors · BSL-1.0

Based on official sources and independently maintained by GetTGAPI. Documentation and glossary →

On this page
  1. Before you start
  2. TDLib Universal Windows Platform example
  3. Building SDK
  4. Example of usage

Before you start

These instructions support existing UWP projects. Check parameter names in build.ps1 at the referenced revision: the upstream prose and example spell the vcpkg argument differently. The source command is preserved unchanged.

TDLib Universal Windows Platform example

This is an example of building TDLib SDK for Universal Windows Platform and an example of its usage from C#.

Building SDK

  • Download and install Microsoft Visual Studio 2017+ with Windows 10 SDK. We recommend to use the latest available versions of Microsoft Visual Studio and Windows 10 SDK.
  • Download and install CMake. CMake 3.13 or newer is required.
  • Install zlib and openssl for all UWP architectures and gperf for x86 using vcpkg:
git clone https://github.com/Microsoft/vcpkg.git
cd vcpkg
git checkout c3867e714dd3a51c272826eea77267876517ed99
.\bootstrap-vcpkg.bat
.\vcpkg.exe install gperf:x86-windows openssl:arm64-uwp openssl:x64-uwp openssl:x86-uwp zlib:arm64-uwp zlib:x64-uwp zlib:x86-uwp
  • (Optional. For XML documentation generation.) Download PHP. Add the path to php.exe to the PATH environment variable.
  • Download and install 7-Zip archiver, which is used by the build.ps1 script to create a Telegram.Td.UWP Visual Studio Extension. Add the path to 7z.exe to the PATH environment variable. Alternatively build.ps1 supports compressing using WinRAR with option -compress winrar and compressing using zip with -compress zip.
  • Build TDLib using provided build.ps1 script (TDLib should be built 6 times for multiple platforms in Debug and Release configurations, so it make take few hours). Pass path to vcpkg.exe as -vcpkg-root argument, for example:
powershell -ExecutionPolicy ByPass .\build.ps1 -vcpkg_root C:\vcpkg

If you need to restart the build from scratch, call .\build.ps1 -vcpkg_root C:\vcpkg -mode clean first.

  • Install Visual Studio Extension "TDLib for Universal Windows Platform" located at build-uwp\vsix\tdlib.vsix, which was created on the previous step by build.ps1 script.

After this TDLib can be used from any UWP project, built in Visual Studio.

Alternatively, you can build TDLib as a NuGet package, adding the option -nupkg to the .\build.ps1 script invocation. The resulting package will be placed in the directory build-uwp\nupkg.

Example of usage

The app/ directory contains a simple example of a C# application for Universal Windows Platform. Just open it with Visual Studio 2015 or later and run.

Continue with the TDLib overview. For credentials, follow the API ID and Hash application process. For portal ERROR assistance, contact GetTGAPI support.

Source license and attribution · BSL-1.0

TDLib contributors · Full license file

Boost Software License - Version 1.0 - August 17th, 2003

Permission is hereby granted, free of charge, to any person or organization
obtaining a copy of the software and accompanying documentation covered by
this license (the "Software") to use, reproduce, display, distribute,
execute, and transmit the Software, and to prepare derivative works of the
Software, and to permit third-parties to whom the Software is furnished to
do so, all subject to the following:

The copyright notices in the Software and this entire statement, including
the above license grant, this restriction and the following disclaimer,
must be included in all copies of the Software, in whole or in part, and
all derivative works of the Software, unless such copies or derivative
works are solely in the form of machine-executable object code generated by
a source language processor.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
DEALINGS IN THE SOFTWARE.