tdlib / td
- пятница, 2 февраля 2018 г. в 03:17:09
Cross-platform library for building Telegram clients
TDLib (Telegram Database library) is a cross-platform library for building Telegram clients. It can be easily used from almost any programming language.
TDLib
has many advantages. Notably TDLib
is:
TDLib
can be used on Android, iOS, Windows, macOS, Linux, Windows Phone, WebAssembly, watchOS, tvOS, Tizen, Cygwin. It should also work on other *nix systems with or without minimal effort.TDLib
can be easily used with any programming language that is able to execute C functions. Additionally it already has native bindings to Java (using JNI) and C# (using C++/CLI).TDLib
takes care of all network implementation details, encryption and local data storage.TDLib
instance handles more than 18000 active bots simultaneously.TDLib
API methods and public interfaces are fully documented.TDLib
guarantees that all updates are delivered in the right order.TDLib
remains stable on slow and unstable Internet connections.TDLib
don't block each other or anything else, responses are sent when they are available.Take a look at our examples and documentation.
TDLib
depends on:
Install all TDLib
dependencies as described in Installing dependencies.
Then enter directory containing TDLib
sources and compile them using CMake:
mkdir build
cd build
cmake -DCMAKE_BUILD_TYPE=Release ..
cmake --build .
brew install gperf cmake openssl
TDLib
with CMake as explained in building. You may need to manually specify path to the installed OpenSSL to CMake, e.g.,cmake -DCMAKE_BUILD_TYPE=Release -DOPENSSL_ROOT_DIR=/usr/local/opt/openssl/ ..
C:\src\vcpkg> .\vcpkg install openssl zlib
TDLib
with CMake as explained in building, but instead of cmake -DCMAKE_BUILD_TYPE=Release ..
use
cmake -DCMAKE_TOOLCHAIN_FILE=C:\src\vcpkg\scripts\buildsystems\vcpkg.cmake ..
For C++ projects that use CMake, the best approach is to build TDLib
as part of your project or to use a prebuilt installation.
There are several libraries that you could use in your CMake project:
For example, part of your CMakeLists.txt may look like this:
add_subdirectory(td)
target_link_libraries(YourTarget PRIVATE Td::TdStatic)
Or you could install TDLib
and then reference it in your CMakeLists.txt like this:
find_package(Td 1.1.0 REQUIRED)
target_link_libraries(YourTarget PRIVATE Td::TdStatic)
See example/cpp/CMakeLists.txt.
TDLib provides native Java interface through JNI.
See example/java for example of using TDLib from Java and detailed build and usage instructions.
TDLib
provides efficient native C++, Java, and C# (will be released soon) interfaces.
But for most use cases we suggest to use the JSON interface. It can be easily used with any language that supports C bindinds. See
example/python/tdjson_example.py for an
example of such usage.
The TDLib is licensed under the terms of the Boost Software License. See LICENSE_1_0.txt for more information.