This document provides a detailed guide for setting up the OneSDK development environment, compiling source code, and running examples on the Windows platform.
- Operating System: Windows 10 or higher
- Architecture: x64 (recommended) or x86
- Memory: At least 4GB RAM
- Disk Space: At least 2GB available space
- Visual Studio 2019 or Visual Studio 2022
- Install the following workloads:
- Desktop development with C++
- CMake tools
- Or install Visual Studio Build Tools
If you don't want to use Visual Studio, you can use MinGW-w64:
- Download and install MSYS2
- Install MinGW-w64 toolchain through MSYS2
- Version Requirement: CMake 3.10+ but not higher than 4.x
- Installation Methods:
- Install through Visual Studio installer
- Or download from CMake official website
- Download and install from Git official website
If TLS support is needed, it's recommended to install OpenSSL:
- Download from OpenSSL official website
- Or install using vcpkg package manager
- Download Visual Studio Installer
- Run the installer and select "Desktop development with C++" workload
- Ensure the following components are selected:
- MSVC v143 compiler toolset
- Windows 10/11 SDK
- CMake tools
- Git for Windows
Set the following environment variables (optional, for custom paths):
set OPENSSL_ROOT_DIR=C:\OpenSSL-Win64
set WINDOWS_SDK_PATH=C:\Program Files (x86)\Windows Kits\10- Download and install MSYS2
- Open MSYS2 terminal and update package database:
pacman -Syu
pacman -S mingw-w64-x86_64-toolchain
pacman -S mingw-w64-x86_64-cmake
pacman -S mingw-w64-x86_64-openssl
pacman -S gitAdd MinGW-w64's bin directory to system PATH:
C:\msys64\mingw64\bin
git clone --recursive https://github.com/volcengine/onesdk.git
cd onesdkEnsure all submodules are properly downloaded:
git submodule update --init --recursiveBefore running examples, you need to obtain the following credentials from the Volcengine IoT Platform console and configure them in the example source code:
- IoT Management API Host:
https://iot-cn-shanghai.iot.volces.com(fixed value) - IoT MQTT Host:
<instance-id>-cn-shanghai.iot.volces.com - Instance ID: Your service instance ID
- Product Key: Required for all authentication types
- Product Secret: Required for "by type" authentication
- Device Name: Required for all authentication types
- Device Secret: Required for "by device" authentication
Note: For "by type" dynamic registration (ONESDK_AUTH_DYNAMIC_PRE_REGISTERED or ONESDK_AUTH_DYNAMIC_NO_PRE_REGISTERED), you must enable the "Enable Dynamic Registration" switch for the product in the console.
Open example files, such as examples/chat/text_image/main_text_image.c, and fill in the credentials obtained in the previous step:
#define SAMPLE_HTTP_HOST "https://iot-cn-shanghai.iot.volces.com"
#define SAMPLE_INSTANCE_ID "<your_instance_id>"
#define SAMPLE_MQTT_HOST "<your_instance_id>.cn-shanghai.iot.volces.com"
#define SAMPLE_PRODUCT_KEY "<your_product_key>"
#define SAMPLE_DEVICE_NAME "<your_device_name>"
// For device-based authentication
#define SAMPLE_DEVICE_SECRET "<your_device_secret>"
// For type-based authentication
#define SAMPLE_PRODUCT_SECRET "<your_product_secret>"Run in the project root directory:
build.batOr
build.ps1Or use CMake GUI:
- Open CMake GUI
- Set source directory to project root directory
- Set build directory to
build - Click "Configure" and select Visual Studio version
- Click "Generate"
- Open the generated Visual Studio solution file for building
Compiled executables are located in the build\Release\ directory:
cd build\examples\chat\chatbot\Release
onesdk_chatbot_example.exeSame as Visual Studio method.
mkdir build
cd build
cmake -G "MinGW Makefiles" ..
mingw32-makecd bin
onesdk_chatbot_example.exeYou can customize the build by passing CMake options to build.bat:
build.bat -D<OPTION_NAME>=<VALUE>You can also pass CMake options through build.ps1:
.\build.ps1 -CMakeOptions @("-D<OPTION_NAME1>=<VALUE1>", "-D<OPTION_NAME2>=<VALUE2>")| Option | Default | Description |
|---|---|---|
ONESDK_ENABLE_AI |
ON |
Enable AI functionality (text, image). |
ONESDK_ENABLE_AI_REALTIME |
ON |
Enable real-time AI functionality (such as WebSocket audio). |
ONESDK_ENABLE_IOT |
ON |
Enable IoT functionality (MQTT, OTA, thing model). |
ONESDK_WITH_EXAMPLE |
ON |
Build example applications. |
ONESDK_WITH_TEST |
OFF |
Build unit tests. |
ONESDK_WITH_SHARED |
ON |
Build shared libraries. |
ONESDK_WITH_STATIC |
ON |
Build static libraries. |
ONESDK_WITH_STRICT_MODE |
OFF |
Enable compiler address sanitizer. |
# Build AI functionality only
build.bat -DONESDK_ENABLE_IOT=OFF
# Build release version
build.bat -DCMAKE_BUILD_TYPE=Release
# Build static libraries only
build.bat -DONESDK_WITH_SHARED=OFF# Release build with examples
.\build.ps1 -BuildType Release -CMakeOptions @("-DONESDK_WITH_EXAMPLE=ON", "-DONESDK_WITH_TEST=ON")
# Release build
.\build.ps1 -BuildType Release -CMakeOptions @("-DONESDK_WITH_EXAMPLE=ON")
# ESP32 source code extraction
.\build.ps1 -CMakeOptions @("-DONESDK_EXTRACT_SRC=ON", "-DONESDK_WITH_TEST=OFF", "-DONESDK_WITH_EXAMPLE=OFF")Solution:
- Install OpenSSL and set environment variables:
set OPENSSL_ROOT_DIR=C:\OpenSSL-Win64
- Or install using vcpkg:
vcpkg install openssl:x64-windows
Solution: Ensure Windows SDK is installed and "Windows 10/11 SDK" is selected in Visual Studio installer.
Solution:
- Ensure CMake version is 3.10 or higher
- Check if all dependency libraries are properly installed
Solution:
- Verify connection and certificates:
curl https://iot-cn-shanghai.iot.volces.com
- If it fails, update the system's CA store
Solution: For "by type" authentication, ensure "Dynamic Registration" is enabled for the product in the IoT console.
Solution:
In the console, go to IoT Platform -> AI Services -> Model Configuration and add the required AI models to your product.
Use multi-core building to speed up compilation:
build.bat --parallel 8Avoid cleaning build directory to leverage incremental compilation:
build.bat- Install C/C++ extension
- Install CMake Tools extension
- Open project folder
- Use Ctrl+Shift+P to open command palette and select "CMake: Configure"
- Open project folder
- CLion will automatically detect CMakeLists.txt
- Configure toolchain as Visual Studio or MinGW
- Open the generated solution in Visual Studio
- Set breakpoints
- Press F5 to start debugging
# Using GDB (MinGW)
gdb onesdk_chatbot_example.exe
# Using Visual Studio debugger
devenv onesdk_chatbot_example.exe