|
|
7 gadi atpakaļ | |
|---|---|---|
| .github | 7 gadi atpakaļ | |
| 3rdparty | 7 gadi atpakaļ | |
| aegis | 8 gadi atpakaļ | |
| afs | 8 gadi atpakaļ | |
| alimt | 7 gadi atpakaļ | |
| arms | 8 gadi atpakaļ | |
| cbn | 7 gadi atpakaļ | |
| ccc | 8 gadi atpakaļ | |
| ccs | 8 gadi atpakaļ | |
| cdn | 7 gadi atpakaļ | |
| chatbot | 8 gadi atpakaļ | |
| cloudauth | 8 gadi atpakaļ | |
| cloudphoto | 7 gadi atpakaļ | |
| cms | 8 gadi atpakaļ | |
| core | 7 gadi atpakaļ | |
| cr | 7 gadi atpakaļ | |
| cs | 8 gadi atpakaļ | |
| csb | 8 gadi atpakaļ | |
| dcdn | 7 gadi atpakaļ | |
| domain | 7 gadi atpakaļ | |
| drds | 8 gadi atpakaļ | |
| dyvmsapi | 8 gadi atpakaļ | |
| ecs | 7 gadi atpakaļ | |
| ehpc | 7 gadi atpakaļ | |
| emr | 7 gadi atpakaļ | |
| ess | 7 gadi atpakaļ | |
| examples | 7 gadi atpakaļ | |
| finmall | 7 gadi atpakaļ | |
| gpdb | 7 gadi atpakaļ | |
| green | 8 gadi atpakaļ | |
| hsm | 8 gadi atpakaļ | |
| iot | 7 gadi atpakaļ | |
| jarvis | 7 gadi atpakaļ | |
| jarvis-public | 7 gadi atpakaļ | |
| linkface | 7 gadi atpakaļ | |
| live | 7 gadi atpakaļ | |
| lubancloud | 7 gadi atpakaļ | |
| mopen | 7 gadi atpakaļ | |
| mts | 7 gadi atpakaļ | |
| openanalytics | 7 gadi atpakaļ | |
| ots | 8 gadi atpakaļ | |
| push | 8 gadi atpakaļ | |
| pvtz | 7 gadi atpakaļ | |
| ram | 7 gadi atpakaļ | |
| rds | 8 gadi atpakaļ | |
| rtc | 7 gadi atpakaļ | |
| saf | 8 gadi atpakaļ | |
| sas-api | 7 gadi atpakaļ | |
| scdn | 7 gadi atpakaļ | |
| slb | 8 gadi atpakaļ | |
| smartag | 8 gadi atpakaļ | |
| snsuapi | 7 gadi atpakaļ | |
| sts | 7 gadi atpakaļ | |
| tesladam | 8 gadi atpakaļ | |
| teslamaxcompute | 7 gadi atpakaļ | |
| teslastream | 7 gadi atpakaļ | |
| test | 7 gadi atpakaļ | |
| tools | 7 gadi atpakaļ | |
| vod | 7 gadi atpakaļ | |
| vpc | 7 gadi atpakaļ | |
| xspace | 7 gadi atpakaļ | |
| .gitignore | 7 gadi atpakaļ | |
| .travis.yml | 7 gadi atpakaļ | |
| CHANGELOG | 7 gadi atpakaļ | |
| CMakeLists.txt | 7 gadi atpakaļ | |
| Doxyfile | 8 gadi atpakaļ | |
| LICENSE | 7 gadi atpakaļ | |
| README.md | 7 gadi atpakaļ | |
| README_zh.md | 7 gadi atpakaļ | |
| VERSION | 7 gadi atpakaļ | |
| easyinstall.sh | 7 gadi atpakaļ | |
| function_test.sh | 7 gadi atpakaļ | |
| generate_code_cov.sh | 7 gadi atpakaļ | |
| unit_test.sh | 7 gadi atpakaļ |
The Alibaba Cloud C++ Software Development Kit (SDK) allows you to access Alibaba Cloud services such as Elastic Compute Service (ECS), Server Load Balancer (SLB), and CloudMonitor. You can access Alibaba Cloud services without the need to handle API related tasks, such as signing and constructing your requests.
This document introduces how to obtain and call Alibaba Cloud C++ SDK.
If you have any problem while using C++ SDK, please submit an issue.
To use Alibaba Cloud C++ SDK, you must have an Alibaba Cloud account and an AccessKey.
The AccessKey is required when initializing the client. You can create an AccessKey in the Alibaba Cloud console. For more information, see Create an AccessKey.
Note: To increase the security of your account, we recommend that you use the AccessKey of the RAM user to access Alibaba Cloud services.
To use Alibaba Cloud C++ SDK to access the APIs of a product, you must first activate the product on the Alibaba Cloud console if required.
C++11 supported compiler installed
CMake 3.0 or newer
4G memory or more
Install third-party libraries on the Linux platform, including libcurl, libopenssl, libuuid, and libjsoncpp.
Run the following commands on the Redhat/Fedora system
sudo dnf install libcurl-devel openssl-devel libuuid-devel libjsoncpp-devel
Run the following commands on the Debian/Ubuntu system
sudo apt-get install libcurl4-openssl-dev libssl-dev uuid-dev libjsoncpp-dev
Run the following commands to clone source codes from GitHub.
git clone https://github.com/aliyun/aliyun-openapi-cpp-sdk.git
Build and install SDK
Manually build and install
cd aliyun-openapi-cpp-sdk
mkdir sdk_build
cd sdk_build
cmake -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr ..
make
sudo make install
Or you may do this with easyinstall.sh in the source directory
cd aliyun-openapi-cpp-sdk
sudo sh easyinstall.sh
The C++ SDK will be installed to /usr.
Install perl.
Run the following command to clone code from Github via git-bash:
git clone https://github.com/aliyun/aliyun-openapi-cpp-sdk.git
Build Visual Studio solution
Change directory to source code and make directory sdk_build
Open CMake UI and
Browse Source to open source code directory.
Browse build to open the created sdk_build directory
Configure
Generate
Open aliyun-openapi-cpp-sdk\\sdk_build\\alibabacloud-sdk.sln with Visual Studio
Select Release
Check INSTALL option from Build -> Configuration Manager
Build->Build Solutions to build.
SDK will be installed to C:\Program File (x86)\alibabacloud-sdk
Before using C++ SDK, you must first configure the preprocessor to define ALIBABACLOUD_SHARED to achieve dynamic linking with Alibaba Cloud C++ SDK shared libraries. Then you must create a client instance, specify the region of cloud services and provide authentication parameters before sending API requests.
The following code shows how to call the DescribeInstances API of ECS to query detailed information of all ECS instances in a specific region.
#include <iostream>
#include <alibabacloud/core/AlibabaCloud.h>
#include <alibabacloud/ecs/EcsClient.h>
using namespace AlibabaCloud;
using namespace AlibabaCloud::Ecs;
int main(int argc, char** argv) {
// Initialize the SDK
AlibabaCloud::InitializeSdk();
// Configure the ECS instance
ClientConfiguration configuration("<your-region-id>");
EcsClient client("<your-access-key-id>", "<your-access-key-secret>", configuration);
// Create an API request and set parameters
Model::DescribeInstancesRequest request;
request.setPageSize(10);
auto outcome = client.describeInstances(request);
if (!outcome.isSuccess()) {
// Handle exceptions
std::cout << outcome.error().errorCode() << std::endl;
AlibabaCloud::ShutdownSdk();
return -1;
}
std::cout << "totalCount: " << outcome.result().getTotalCount() << std::endl;
// Close the SDK
AlibabaCloud::ShutdownSdk();
return 0;
}
Copy the above to ecs_test.cc, then build with the following command.
~$ g++ -o ecstest ecs_test.cc --std=c++11 -lalibabacloud-sdk-core -l alibabacloud-sdk-ecs
~$ ./ecstest
# Result or error message will be shown here.
~$
More examples
Please refer to LICENSE (Apache 2.0 LICENSE).