C++ SDK
To compile on Linux, install the dependent external libraries: libcurl, libopenssl, libuuid, and libjsoncpp.
Install a compiler that supports C++ 11 or later:
Windows: Visual Studio 2015 or later
Linux: GCC 4.9 or later
Install CMake 3.0 or later.
A minimum of 4 GB of memory is required.
(1) Download or clone aliyun-openapi-cpp-sdk from GitHub.
Download directly from https://github.com/aliyun/aliyun-openapi-cpp-sdk/archive/master.zip
Use the Git command.
git clone https://github.com/aliyun/aliyun-openapi-cpp-sdk.git
(2) Create the necessary build files.
cd aliyun-openapi-cpp-sdk
mkdir sdk_buildThe file structure for the Machine Translation C++ SDK is as follows:
- /aliyun-openapi-cpp-sdk
--- /alimt
--- /core
--- /sdk_build
--- easyinstall.sh
--- CMakeLists.txt
(3) Replace the content of CMakeLists.txt with the following:
cmake_minimum_required(VERSION 3.1)
cmake_policy(SET CMP0048 NEW)
file(STRINGS "VERSION" version)
project(alibabacloud-sdk VERSION ${version})
message(STATUS "Project version: ${PROJECT_VERSION}")
set(TARGET_OUTPUT_NAME_PREFIX "alibabacloud-sdk-" CACHE STRING "The target's output name prefix")
option(BUILD_SHARED_LIBS "Enable shared library" ON)
option(BUILD_UNIT_TESTS "Enable unit tests" OFF)
option(BUILD_FUNCTION_TESTS "Enable function test" OFF)
set(LIB_TYPE STATIC)
if(BUILD_SHARED_LIBS)
set(LIB_TYPE SHARED)
add_definitions(-DALIBABACLOUD_SHARED)
endif()
set_property(GLOBAL
PROPERTY
USE_FOLDERS ON)
set(CMAKE_CXX_STANDARD 11)
include(ExternalProject)
include(GNUInstallDirs)
add_subdirectory(3rdparty)
add_subdirectory(core)
if(BUILD_UNIT_TESTS)
enable_testing()
add_subdirectory(test/core)
endif()
if(BUILD_FUNCTION_TESTS)
enable_testing()
add_subdirectory(test/function_test/cdn)
add_subdirectory(test/function_test/core)
add_subdirectory(test/function_test/cs)
add_subdirectory(test/function_test/ecs)
add_subdirectory(test/function_test/nlp)
add_subdirectory(test/function_test/rds)
add_subdirectory(test/function_test/slb)
add_subdirectory(test/function_test/vpc)
endif()
add_subdirectory(alimt)
(4) Run the easyinstall.sh script for a one-click installation.
cd aliyun-openapi-cpp-sdk
sudo sh easyinstall.sh
The Alibaba Cloud SDK for C++ is installed in /usr.
Procedure
Follow these steps to get started with the Machine Translation C++ SDK.
Step 1: Create an Alibaba Cloud account
For more information, see Sign up for an Alibaba Cloud account.
You must complete identity verification to use all Alibaba Cloud services. Some services are unavailable until this process is complete.
Step 2: Obtain an AccessKey pair
To use the Machine Translation C++ SDK, you need an Alibaba Cloud AccessKey pair.
Log on to the Alibaba Cloud key management page. Select an AccessKey pair to use with the SDK. If you do not have an AccessKey pair, create one and make sure it is enabled. An AccessKey pair consists of an AccessKey ID and an AccessKey secret.
Keep this key pair confidential. You will need it for the following steps.
Step 3: Start a C++ program
For sample code, see SDK Demo (C++).