Example Source Code Running Guide
This article introduces how to quickly run through the example source code and experience the basic audio and video call service.
Prepare Environment
Please ensure that the development environment meets the following technical requirements:
-
Windows: Windows 7 or above, with Visual Studio 2019 or above installed.
-
macOS: macOS 11.0 or above, with Xcode 15.0 or above installed.
-
Linux: Any Linux distribution system with GLIBC 2.16 or above, supporting x86_64, aarch64, armhf architectures.
Note- Linux RTC SDK only supports custom video rendering and does not support SDK automatic rendering (that is, the ZegoCanvas parameters for preview and playing stream are invalid). Therefore, in the example Demo, except for the custom video rendering topic, no images can be displayed.
- You can refer to the Custom Video Rendering document and the example code in the "ZegoExpressExample/Examples/AdvancedVideoProcessing/CustomVideoRendering" directory of this Demo to implement rendering and displaying preview or playing stream images on Linux Qt.
-
Other general requirements:
- CMake installed: Download CMake.
- Qt installed (version 5.9 ~ 5.15): Download Qt. For developers using Qt for the first time, you can read its official tutorial to learn how to use it.
- External devices such as microphones and cameras that support audio and video functions are working properly.
WarningQtCreator versions prior to 8.0.1 may encounter issues where the Demo crashes because it cannot request camera and microphone permissions when debugging this Demo on macOS 12 Monterey or above. For details, refer to this issue.
Solution: Download and install QtCreator 8.0.2 or above, and do not use the QtCreator that comes with the Qt5 installation package.
Developers can download from QtCreator Github Release or Qt official website, or use HomeBrew to install:
brew update && brew install --cask qt-creator
Prerequisites
A project has been created in the ZEGOCLOUD Console, and valid AppID and AppSign have been obtained.
The SDK also supports Token authentication. If you need to upgrade the authentication method, please refer to How to upgrade from AppSign authentication to Token authentication.
After installing CMake and Qt, you need to add environment variables. The CMake and Qt paths provided below are for reference only. Users need to fill in according to the actual paths on their devices.
-
Windows system:
- Modify environment variables: Add
C:\Program Files\CMake\binto Path. - Modify environment variables: Add
C:\Qt\Qt5.12.12\5.12.12\msvc2017\binto Path. - Add user variable: Add
QTDIRuser variable asC:\Qt\Qt5.12.12\5.12.12\msvc2017
- Modify environment variables: Add
-
macOS system:
export PATH="$PATH:$HOME/Qt5.12.12/5.12.12/clang_64/bin" export QTDIR="$HOME/Qt5.12.12/5.12.12/clang_64" -
Linux system:
export QTDIR="/usr/local/Qt-5.12.12" export PATH="$PATH:$QTDIR/bin" export LD_LIBRARY_PATH="$QTDIR/lib:$LD_LIBRARY_PATH"
Obtain Example Source Code
Local Download
This example source code is a desktop cross-platform Qt5 C++ application that supports both Windows/macOS/Linux platforms. The example source code comes with the latest version of SDK packages for all three platforms and can be run directly.
Example Source Code Directory Structure
The following structure is the file structure of the video subdirectory. All file paths involved below are relative to this directory.
.
├── README_zh.md
├── README.md
├── libs
│ ├── ScreenCapture
│ └── ZegoExpress
│ ├── linux # Directory for ZegoExpressVideo Linux SDK
│ ├── mac # Directory for ZegoExpressVideo macOS SDK
│ │ └── ZegoExpressEngine.xcframework
│ └── win # Directory for ZegoExpressVideo Windows SDK
│ ├── x64
│ └── x86
└── ZegoExpressExample
├── KeyCenter.cpp # Fill in the applied AppID and AppSign
├── KeyCenter.h
├── ZegoExpressExample.pro # Qt project file
├── Examples
├── HomePage
...Run Example Source Code
-
Modify the "/ZegoExpressExample/KeyCenter.cpp" file and fill in the "AppID" and "AppSign" required for SDK initialization.
WarningPlease use the AppID and AppSign obtained in Prerequisites of this article to fill in correctly, otherwise the example source code cannot run normally.

-
Open the project.
Use QtCreator to open the "./ZegoExpressExample/ZegoExpressExample.pro" project file.
-
Compile and run the project.
-
Method 1: Run or Build directly through QtCreator.
After opening the Qt project, click the "Run", "Debug", or "Build" buttons in the lower left corner to build and run the Demo.
-
Method 2: Build through qmake and make.
-
Windows
- Open cmd.exe and execute the
cd \path\to\this\foldercommand to enter the directory where this file is located. - Find the path to "vcvarsall.bat" (for example, VS 2019 version is in "C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Auxiliary\Build\vcvarsall.bat").
- Execute the
call "\path\to\your\vcvarsall.bat" x86command to set the MSVC environment. - Execute the
qmake ZegoExpressExample\ZegoExpressExample.pro CONFIG+=Win32 -o .\build\Makefilecommand to generate Makefile through qmake. - Execute the
cd buildcommand to enter the build directory, and build the project through thenmakecommand. - Execute the
cd ..command to return to the upper directory, and deploy the Qt App through thewindeployqt .\bin\release\ZegoExpressExample.execommand.
- Open cmd.exe and execute the
-
macOS
- Open the terminal and execute the
cd /path/to/this/foldercommand to enter the directory where this file is located. - Execute the
qmake ZegoExpressExample/ZegoExpressExample.pro CONFIG+=x86_64 -o ./build/Makefilecommand to generate Makefile through qmake. - Execute the
cd buildcommand to enter the build directory, and build the project through themakecommand. - Execute the
cd ..command to return to the upper directory, and deploy the Qt App through themacdeployqt ./bin/release/ZegoExpressExample.appcommand.
- Open the terminal and execute the
-
Linux
- Open the terminal and enter the directory where the file is located
cd /path/to/this/folder. - Select compilation environment
- Native compilation (supports x86_64, aarch64, armhf)
- Execute
qmake ZegoExpressExample/ZegoExpressExample.pro -o ./build/Makefileto generate Makefile through qmake. - Execute
cd buildto enter the build directory and executemaketo build the project. - In the
bin/releasedirectory of the upper directory, find theZegoExpressExampleproject file, which can be run.
- Execute
- Cross compilation
- Currently supports cross-compiling for aarch64 or armhf target platforms in x86_64 environment (if you need to support other environments, please modify the configuration in
ZegoExpressExample.proyourself). - Confirm that your machine has installed Qt everywhere for cross-compilation for the target platform. The following assumes cross-compilation for the aarch64 target platform and the corresponding Qt has been installed to the
/usr/aarch64-linux-gnu/Qt-5.12.12directory. - Execute
export TARGET_LINUX_ARCH=aarch64. This environment variable is to helpZegoExpressExample.proidentify the target platform to be built. - Execute
/usr/aarch64-linux-gnu/Qt-5.12.12/bin/qmake ZegoExpressExample/ZegoExpressExample.pro -o ./build/Makefile -spec linux-aarch64-gnu-g++to generate Makefile for the aarch64 target platform through qmake. - Execute
cd buildto enter the build directory and executemaketo build the project. - Copy the products in the
bin/releasedirectory and the/usr/aarch64-linux-gnu/Qt-5.12.12/libdirectory to your target platform, and you can run it.
- Currently supports cross-compiling for aarch64 or armhf target platforms in x86_64 environment (if you need to support other environments, please modify the configuration in
- Native compilation (supports x86_64, aarch64, armhf)
- Open the terminal and enter the directory where the file is located
-
-
Experience Audio and Video Call/Live Streaming Functions
Run the project on the real device. After successful operation, you can see the local video screen.
For convenience, ZEGO provides a Web platform for debugging. On this page, enter the same AppID and RoomID, enter different UserIDs and corresponding Token, and you can join the same room to communicate with the real device. When the audio and video call starts successfully, you can hear the remote audio and see the remote video screen.
