You need to enable JavaScript to run this app.
Torch Object Storage

Torch Object Storage

Copy page
Download PDF
C++
Installing the C++ SDK
Copy page
Download PDF
Installing the C++ SDK
This article introduces the download address and installation method for the TOS C++ SDK.​
Environmental Preparation​
Before installing the TOS C++ SDK, ensure that the following dependencies have been installed:​
  • C++11 or later versions​
  • CMake version 3.1 or higher​
  • GCC version 4.8 or later​
  • Clang version 3.3 and later​
  • Visual Studio 2019 or later is required in the Windows environment.​
Download Link​
Installation Method​
warning​
The C++ SDK is currently not supported for installation or use on Android or Linux ARM systems.​
​
Compiling from Source Code
Linux
macOS
Windows
​
warning​
The SDK depends on the libcurl and openssl libraries. Before building the SDK, please ensure that both libraries have been installed.​
  1. Download the source code. You may download the source code using the following methods:​
  • Direct download: See the source code address for the TOS C++ SDK at TOS C++ SDK. The latest version is determined by the updates in Git.​
  • Download via Git: Execute the following command to clone the source code to your local machine.​
  • ​
    git clone https://github.com/volcengine/ve-tos-cpp-sdk​
    ​
  1. Execute the following command to build using CMake version 3.1 or above.​
  • ​
    cd ve-tos-cpp-sdk​
    mkdir build​
    cd build​
    ​
​
CMake Compilation Options​
BUILD_SHARED_LIB​
Disabled by default; CMake compiles only static libraries by default. After opening the project, CMake will simultaneously compile both the static and dynamic libraries, and at the same time, the SDK will link to the dynamic library.​
​
cmake .. -DBUILD_SHARED_LIB=ON​
​
warning​
The BUILD_SHARED_LIB compilation option is currently not supported in the Windows environment.​
BUILD_DEMO​
Disabled by default. After opening the project, CMake will compile the examples in the example folder, which can then be run directly. Refer to the examples in the example folder.​
​
cmake .. -DBUILD_DEMO=ON​
​
BUILD_UNITTEST​
Disabled by default. After opening the project, CMake will compile the unit test cases in the test folder. Note that if you need to compile the unit test section, cmake must be greater than version 3.14.​
​
cmake .. -DBUILD_UNITTEST=ON​
​
Upgrade to Version 2​
To upgrade to TOS C++ SDK V2, you must modify the client initialization method. Compared to the V1 version, the V2 version has the following characteristics:​
  • Enhanced interface capabilities: V2 supports a broader range of interfaces and is continuously improved.​
  • Additional value-added features are available, with certain V2 interfaces supporting event callbacks, progress notifications, rate limiting, and other value-added features.​
tip​
New features will not be added to Version V1 in the future; we recommend using Version V2.​
Before modification​
The initialization of the TosClient client is as follows.​
​
#include "TosClient.h"​
using namespace VolcengineTos;​
int main(void){​
std::string endpoint = "Your Endpoint";​
std::string region = "Your Region";​
​
std::string accessKey = std::getenv("TOS_ACCESS_KEY");​
std::string secretKey = std::getenv("TOS_SECRET_KEY");​
​
InitializeClient();​
​
TosClient client(endpoint, region, accessKey, secretKey);​
/*​
​
*/​
CloseClient();​
return 0;​
}​
​
Revised​
Initialize the TosClientV2 client as follows.​
​
#include "TosClientV2.h"​
using namespace VolcengineTos;​
int main(void){​
​
​
std::string region = "Your Region";​
std::string accessKey = std::getenv("TOS_ACCESS_KEY");​
std::string secretKey = std::getenv("TOS_SECRET_KEY");​
​
​
InitializeClient();​
​
TosClientV2 client(region, accessKey, secretKey);​
​
/*​
​
*/​
​
CloseClient()​
return 0;​
}​
​
warning​
The initialization parameters for the client have changed in the upgrade to V2: the endpoint parameter, which was the first required parameter in Client V1, has been modified to an optional parameter in Client V2. If you still need to specify the endpoint, please refer to Setting Optional Parameters for detailed steps.​
Last updated: 2025.09.25 14:22:44