tdlib / td

Cross-platform library for building Telegram clients
https://core.telegram.org/tdlib
Boost Software License 1.0
7.11k stars 1.44k forks source link

How to open the source code in Visual Studio? #2512

Closed AqlaSolutions closed 1 year ago

AqlaSolutions commented 1 year ago

I'm new to C++. There are no vcproj files. How to open the source code in Visual Studio for normal edit, compile, debug experience?

What IDE do you use on Windows to develop this library?

levlam commented 1 year ago

See https://github.com/tdlib/td#building.

Also, new enough Visual Studio supports CMake out of the box. See https://learn.microsoft.com/en-us/cpp/build/cmake-projects-in-visual-studio for more details.

AqlaSolutions commented 1 year ago

As stated in the linked docs I need to open a folder with CMakeLists.txt. The folder \td\telegram\ doesn't contain it. If I try to open root folder VS shows this error:

Error at D:\tgproj\td-master\CMakeLists.txt:9 (project): No CMAKE_CXX_COMPILER could be found. Tell CMake where to find the compiler by setting either the environment variable "CXX" or the CMake cache entry CMAKE_CXX_COMPILER to the full path to the compiler, or to the compiler name if it is in the PATH

Previously I successfully built entire project from command line (from different directory) using the build instructions. So I have all tools required.

Also the https://github.com/tdlib/td#building link only contains instructions for building from command line which doesn't answer my question at all.

levlam commented 1 year ago

No, it answers your question. See, what is CMake: https://en.wikipedia.org/wiki/CMake.

levlam commented 1 year ago

CMake isn't a build tool. To build a project with MSVC compiler it generates a Visual Studio solution with multiple projects in the build directory. You can open the solution build/TDLib.sln in Visual Studio.

Alternatively, you can open the TDLib root directory in Visual Studio. It will be able to find CMakeLists.txt and build the project using it by creating a solution inside "out" subdirectory. Given, OpenSSL and zlib are required to build TDLib, you will also need to change "CMake Settings for TDLib" by right-clicking the CMakeLists.txt file, choosing corresponding menu item, and adding <full path to vcpkg>/vcpkg/scripts/buildsystems/vcpkg.cmake as CMake toolchain file. Also, don't forget to delete and regenerate CMake cache after changing the toolchain file if you tried to build the project before specifying the toolchain file.