安裝支援 C++ 11 或更高版本的編譯器:
安裝 CMake 3.0 或以上版本
建議 4G 或以上記憶體
(1) 從 GitHub 下載或 Git 複製 aliyun-openapi-cpp-sdk
(2) 建立產生必要的構建檔案
cd aliyun-openapi-cpp-sdk
mkdir sdk_build
機器翻譯 C++ SDK 使用主要檔案結構如下:
- /aliyun-openapi-cpp-sdk
--- /alimt
--- /core
--- /sdk_build
--- easyinstall.sh
--- CMakeLists.txt
(3) CMakeLists.txt使用如下檔案替換
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)通過 easyinstall.sh一鍵式安裝
cd aliyun-openapi-cpp-sdk
sudo sh easyinstall.sh
Alibaba Cloud SDK for C++ 將被安裝在 /usr.
操作步驟
為快速開始使用機器翻譯 C++ SDK,請按照如下步驟進行。
步驟 1 建立阿里雲帳號
具體方法請參考阿里雲帳號註冊流程。
為了更好地使用阿里雲服務,建議儘快完成實名認證,否則部分阿里雲服務將無法使用。
步驟 2 擷取阿里雲存取金鑰
為了使用機器翻譯 C++ SDK,您必須申請阿里雲的存取金鑰。
登入阿里雲密鑰管理頁面 。選擇一對用於 SDK 的存取金鑰對。如果沒有,請建立一對新存取金鑰,且保證它處於啟用狀態。 密鑰指的是Access Key ID和Access Key Secret
該金鑰組會在下面的步驟使用,且需要保管好,不能對外泄露。