All Products
Search
Document Center

Object Storage Service:Installation (C SDK)

Last Updated:Mar 20, 2026

Install the OSS C SDK to manage buckets, upload and download objects, and process images.

On this page

Prerequisites

Before you begin, ensure that you have:

  • GCC and G++ compilers, version 4.8 or later (required for C99 and GNU99 syntax support)

Dependencies

The OSS C SDK requires CMake and three third-party libraries. Install these before building the SDK.

DependencyPurposeVersion
CMakeBuild tool3.10.0 or later
curlNetwork communication7.32.0 or later
apr-utilMemory management and cross-platform support1.5.2 or later
minixmlParses XML responses2.9 (recommended)

Install on Linux

Step 1: Install CMake

Run the command for your distribution:

Ubuntu/Debian

sudo apt-get install cmake

Red Hat/Alibaba Cloud Linux/CentOS

sudo yum install cmake

SuSE

sudo zypper install cmake

Step 2: Install the dependency libraries

Run the commands for your distribution:

Ubuntu/Debian

Install all dependency libraries with a single command:

sudo apt-get install libcurl4-openssl-dev libapr1-dev libaprutil1-dev libmxml-dev

Red Hat/Alibaba Cloud Linux/CentOS

  1. Install curl:

       yum -y install libcurl-devel
  2. Install apr and apr-util:

       yum install apr-util
       yum install apr-devel
       yum install apr-util-devel
  3. Install minixml from source:

       wget "https://github.com/michaelrsweet/mxml/releases/download/release-2.9/mxml-2.9.tar.gz"
       tar zxf mxml-2.9.tar.gz
       cd mxml-2.9
       ./configure
       make
       sudo make install

SuSE

sudo zypper install libcurl-devel libapr1-devel libapr-util1-devel mxml-devel

Step 3: Install the SDK

The following example uses OSS C SDK version 3.10.0. For the latest release, see GitHub.

  1. Download and decompress the SDK source package:

       tar zxf aliyun-oss-c-sdk-3.10.0.tar.gz
       cd aliyun-oss-c-sdk-3.10.0
  2. Build and install:

       cmake .
       make
       sudo make install

Custom installation paths

If curl, apr, apr-util, or minixml are installed in non-default locations, specify their paths during the build. Replace the paths below with the actual locations on your system:

cmake -f CMakeLists.txt \
  -DCMAKE_BUILD_TYPE=Release \
  -DCMAKE_INSTALL_PREFIX=/usr/local/ \
  -DCURL_INCLUDE_DIR=/usr/include/curl \
  -DCURL_LIBRARY=/usr/lib64/libcurl.so \
  -DAPR_INCLUDE_DIR=/usr/include/apr-1 \
  -DAPR_LIBRARY=/usr/lib64/libapr-1.so \
  -DAPR_UTIL_INCLUDE_DIR=/usr/include/apr-1 \
  -DAPR_UTIL_LIBRARY=/usr/lib64/libaprutil-1.so \
  -DMINIXML_INCLUDE_DIR=/usr/include \
  -DMINIXML_LIBRARY=/usr/lib64/libmxml.so

-DCMAKE_BUILD_TYPE accepts Debug, Release, RelWithDebInfo, and MinSizeRel. The default is Debug.

Step 4: Compile and run the sample project

  1. Download and decompress the sample project:

       wget https://docs-aliyun.cn-hangzhou.oss.aliyun-inc.com/assets/attach/32132/cn_zh/1487730555529/aliyun-oss-c-sdk-demo.tar.gz
       tar zxf aliyun-oss-c-sdk-demo.tar.gz
  2. Open the sample code and replace the placeholder values:

    PlaceholderDescription
    OSS_ENDPOINTYour OSS endpoint, for example https://oss-cn-hangzhou.aliyuncs.com
    ACCESS_KEY_IDYour AccessKey ID
    ACCESS_KEY_SECRETYour AccessKey Secret
    BUCKET_NAMEThe name of your bucket
    Note

    When installing oss-c-sdk-demo-specified-installation, specify the installation directory, for example /home/your/oss/csdk. Other sample projects use the default installation paths and do not require a custom directory. For detailed steps, see Use the Alibaba Cloud OSS C SDK on Linux.

  3. Navigate to the project directory (oss-c-sdk-demo-xxx) and compile:

       make
  4. Run the sample:

       ./main

    To recompile from scratch, run make clean first.

    Note

    If the OSS C SDK dynamic libraries or their dependency libraries are not in a system library path, set LD_LIBRARY_PATH to their location before running the program.

Install on Windows

  1. Download the OSS C SDK:

  2. Download the sample project:

  3. Open oss_config.c and replace the following placeholders with valid values: OSS_ENDPOINT, ACCESS_KEY_ID, ACCESS_KEY_SECRET, BUCKET_NAME, OBJECT_NAME, MULTIPART_UPLOAD_FILE_PATH, and DIR_NAME.

  4. Use Visual Studio 2012 or later to compile the sample project. For detailed steps and frequently asked questions, see Compile and use the Alibaba Cloud OSS C SDK on Windows.

    Note

    Visual Studio may prompt you to upgrade the project to use the latest compiler and libraries. Match the editor and library versions to your project version. If your project is compatible with the latest compiler and libraries, click Upgrade. Otherwise, skip the upgrade.

Troubleshooting

`Could not find apr-config/apr-1-config`

The apr-1-config binary is not in the default path. Add the following flag to your cmake command:

-DAPR_CONFIG_BIN=/path/to/bin/apr-1-config

`Could not find apu-config/apu-1-config`

The apu-1-config binary is not in the default path. Add the following flag to your cmake command:

-DAPU_CONFIG_BIN=/path/to/bin/apu-1-config