文档

C++ SDK

更新时间:

要在 Linux 平台进行编译, 您必须安装依赖的外部库文件 libcurl、libopenssl、libuuid、libjsoncpp。

  • 安装支持 C++ 11 或更高版本的编译器:

    • Windows: Visual Studio 2015 或以上版本

    • Linux: GCC 4.9 或以上版本

  • 安装 CMake 3.0 或以上版本

  • 建议 4G 或以上内存

(1) 从 GitHub 下载或 Git 克隆 aliyun-openapi-cpp-sdk

  • 直接下载 https://github.com/aliyun/aliyun-openapi-cpp-sdk/archive/master.zip

  • 使用 Git 命令获取

git clone https://github.com/aliyun/aliyun-openapi-cpp-sdk.git

(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

该密钥对会在下面的步骤使用,且需要保管好,不能对外泄露。

步骤 3 开始一个 C++ 程序

示例代码详见SDK示例(C++)

  • 本页导读 (0)
文档反馈