tencent cloud

Tencent Real-Time Communication

Política TRTC
Política de privacidade
Contrato de segurança e processamento de dados
DocumentaçãoTencent Real-Time Communication

Windows C++ & Qt

Modo Foco
Tamanho da Fonte
Última atualização: 2022-05-19 10:26:57
This document describes how to quickly integrate the TRTC Windows C++ SDK using a Qt project.

Environment Requirements

OS: Windows 7 or later
Development environment: Visual Studio 2010 or later (v2015 is recommended)

Integrating the C++ SDK via a Qt Project

The following describes how to integrate the TRTC Windows C++ SDK into a Qt project in Visual Studio.

Step 1. Download the SDK

Download the latest version of the TRTC SDK.
You only need to import the SDK files for Windows C++ in the SDK folder. For example, you can find the SDK files for 64-bit Windows in ./SDK/CPlusPlus/Win64/. The folder contains the following files:
Directory
Description
include
API header files with comments
lib
The LIB file for compilation and DLL files to load

Step 2. Create a project

Take Visual Studio 2015 for example. Make sure you have installed Qt and Qt Visual Studio Add-in. Then, open Visual Studio and create a Qt application named TRTCDemo.



For the example in this guide, we will choose Qt Widgets Application. Click Add, and then click Next in subsequent steps until the project is created.

Step 3. Copy and paste files

Copy the SDK folder to the directory where TRTCDemo.vcxproj is located.
Note:
Because you will only need the C++ SDK, you can delete the CSharp folder in SDK.




Step 4. Modify project configuration

Select Solution Explorer, right-click TRTCDemo, and select Properties. Configure the project as follows:
1. Add include directories.
Go C/C++ > General. Add the $(ProjectDir)SDK\\CPlusPlus\\Win64\\include and $(ProjectDir)SDK\\CPlusPlus\\Win64\\include\\TRTC header file directories (for 64-bit Windows) to Additional Include Directories.
Note:
For 32-bit Windows, add $(ProjectDir)SDK\\CPlusPlus\\Win32\\include and $(ProjectDir)SDK\\CPlusPlus\\Win32\\include\\TRTC.



2. Add additional library directories
Go to Linker > General. Add the $(ProjectDir)SDK\\CPlusPlus\\Win64\\lib directory (for 64-bit Windows) to ** Additional Library Directories**.
Note:
For 32-bit Windows, add $(ProjectDir)SDK\\CPlusPlus\\Win32\\lib.



3. Add the library file.
Go to Linker > Input, and add the library file liteav.lib to Additional Dependencies.



4. Add the copy command
Go to Build Events > Post-build Events and add the copy command copy /Y $(ProjectDir)SDK\\CPlusPlus\\Win64\\lib\\*.dll $(OutDir) (for 64-bit Windows) to Command Line. This ensures that the DLL files of the SDK are automatically copied to the project’s execution directory after compilation
Note:
For 32-bit Windows, add copy /Y $(ProjectDir)SDK\\CPlusPlus\\Win32\\lib\\*.dll $(OutDir).




Step 5. Print the SDK version number

1. At the top of the TRTCDemo.cpp file, add the code below to import the header file:
#include "ITRTCCloud.h"
#include <QLabel>
2. In the TRTCDemo::TRTCDemo constructor of TRTCDemo.cpp, add the following testing code:
ITRTCCloud * pTRTCCloud = getTRTCShareInstance();
std::string version(pTRTCCloud->getSDKVersion());

QString sdk_version = QString("SDK Version: %1").arg(version.c_str());
QLabel* label_text = new QLabel(this);
label_text->setAlignment(Qt::AlignCenter);
label_text->resize(this->width(), this->height());
label_text->setText(sdk_version);
3. Press F5 to run the project and print the version number of the SDK.




FAQs

If the following error occurs, check whether the SDK header file directories are correctly added as described in the project configuration step above.
fatal error C1083: Could not open include file: “TRTCCloud.h”: No such file or directory
If the following error occurs, check whether the SDK library directory and library file are correctly added as described in the project configuration step above.
error LNK2019: unresolved external symbol "__declspec(dllimport) public: static class TXString __cdecl TRTCCloud::getSDKVersion(void)" (__imp_?getSDKVersion@TRTCCloud@@SA?AVTXString@@XZ), referenced in function "protected: virtual int __thiscall CTRTCDemoDlg::OnInitDialog(void)" (?OnInitDialog@CTRTCDemoDlg@@MAEHXZ)


Ajuda e Suporte

Esta página foi útil?

comentários