TDLib

TDLib C++ 接入与运行

使用 CMake 安装 TDLib,设置 Td_DIR,构建 C++ 示例并处理运行时共享库。

GetTGAPI 编辑团队更新于
TDLib 文档核对日期

来源版本 a94b83d67ab4 · TDLib contributors · BSL-1.0

依据官方资料整理,由 GetTGAPI 独立维护。 文档目录与术语表 →

本页内容
  1. 开始之前
  2. TDLib C++ 基本用法示例

开始之前

先构建库,再构建示例。编译成功不代表运行时能找到全部动态库;请分别核对链接路径、运行时路径和目标架构。

TDLib C++ 基本用法示例

应先构建 TDLib,并安装到本地子目录 td/:

cd <path to TDLib sources>
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX:PATH=../example/cpp/td ..
cmake --build . --target install

有关构建的更多细节,另见 构建说明。

然后可以构建示例:

cd <path to TDLib sources>/example/cpp
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release -DTd_DIR=<full path to TDLib sources>/example/cpp/td/lib/cmake/Td ..
cmake --build .

所有可用类和方法的文档见 https://core.telegram.org/tdlib/docs。

运行示例时,可能需要手动将所需共享库从 td/bin 复制到生成的可执行文件所在目录。

继续阅读 TDLib 总览与构建。需要应用凭证时,可参考 API ID 与 Hash 申请流程;申请遇到 ERROR,可通过 GetTGAPI 客服 沟通。

原文许可与归属 · BSL-1.0

TDLib contributors · 完整许可文件

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.