edit-icon download-icon

Installation

Last Updated: Nov 03, 2017

Prerequisites

  • You must have an active Alibaba Cloud OSS account. You must create an AccessKey ID and an AccessKey Secret.

  • If you want more information about OSS service and want to activate the OSS service, log on to the OSS product homepage to learn more.

  • If you have not created an AccessKey ID and an AccessKey Secret, go to Alibaba Cloud Access Key Management to create an AccessKey.

Linux

Environment dependency

In OSS C-SDK, cURL is required for network operations on both clients and servers.

Besides, OSS C-SDK uses the APR and APR-Util libraries for memory management and cross-platform operations. It also used the Mini-XML library for parsing XML returned by a request.

These libraries are not included in OSS C-SDK (for Linux). Install these libraries and add their header file directories, and the library file directories to the project.

Install a third-party library

Ubuntu/Debian

  • Install CMake

    Run the following command to install CMake.

    1. sudo apt-get install cmake
  • Install a third-party library

    Run the following command to install a third-party library.

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

RedHat/Aliyun/CentOS

  • Install CMake

    Run the following command to install CMake.

    1. sudo yum install cmake
  • Install a third-party library

    Run the following command to install a third-party library.

    1. sudo yum install curl-devel apr-devel apr-util-devel
  • Mini-XML

    Download the matching RPM package for the system:

    Run the following command to install Mini-XML.

    1. rpm -ivh mxml-2.9-1.x86_64.rpm

SuSE

  • Install CMake

    Run the following command to install CMake.

    1. zypper install cmake
  • Install a third-party library

    Run the following command to install a third-party library.

    1. zypper install libcurl-devel libapr1-devel libapr-util1-devel mxml-devel

Other Linux

  • CMake (Version 2.6.0 and later are recommended)

    Click here to download. A typical installation method is as follows:

  1. ./configure
  2. make
  3. make install

Note: When you run the ./configure command, the default installation directory is /usr/local/. To specify another installation directory, use ./configure --prefix=/your/install/path/.

  • libcurl (Version 7.32.0 and later are recommended)

    Download from here and install it by referring to libcurl Installation Guide. A typical installation approach is as follows:

  1. ./configure
  2. make
  3. make install

Note:

  • When you run the ./configure command, the default installation directory is /usr/local/. To specify another installation directory, use ./configure --prefix=/your/install/path/.
  • If you want to use MEDIA-C-SDK, make sure HTTPS is contained in the last row of Protocols after the ./configure command is executed. If not, install openssl-devel or another SSL development kit first and re-install libcurl.
  • APR (Version 1.5.2 and later are recommended)

    Click here to download. A typical installation method is as follows:

  1. ./configure
  2. make
  3. make install

Note: When you run the ./configure command, the default installation directory is /usr/local/. To specify another installation directory, use ./configure --prefix=/your/install/path/.

  • APR-Util (Version 1.5.4 and later are recommended)

    Click here to download. The --with-apr option must be specified during installation. A typical installation method is as follows:

    1. ./configure --with-apr=/your/apr/install/path
    2. make
    3. make install

    Note:

    • When you run the ./configure command, the default installation directory is /usr/local/. To specify another installation directory, use ./configure --prefix=/your/install/path/.
    • You must specify the APR installation directory through --with-apr. To install APR under a system directory, specify --with-apr=/usr/local/apr/.
  • Mini-XML (Version 2.9 is recommended)

    Click here to download. A typical installation method is as follows:

  1. ./configure
  2. make
  3. sudo make install

Note:

  • We recommend you use version 2.9 minixml.
  • When you run the ./configure command, the default installation directory is /usr/local/. To specify another installation directory, use ./configure --prefix=/your/install/path/.

Compile and install OSS C SDK

A typical compiling command is as follows:

  1. cmake .
  2. make
  3. make install

Note:

  • When you run the cmake . command, the cURL, APR, APR-Util and Mini-XML header files and library files are searched for in the directory /usr/local/ by default.
  • The default compilation type is Debug, but you can specify the following types for compilation: Debug, Release, RelWithDebInfo, and MinSizeRel. To use the Release compilation type, run the command cmake -f CMakeLists.txt -DCMAKE_BUILD_TYPE=Release.

  • If You have specified installation directories for cURL, APR, APR-Util and Mini-XML, you must specify the paths of these libraries when running CMake.

    • For example, cmake -f CMakeLists.txt -DCURL_INCLUDE_DIR=/usr/local/include/curl/ -DCURL_LIBRARY=/usr/local/lib/libcurl.so -DAPR_INCLUDE_DIR=/usr/local/include/apr-1/ -DAPR_LIBRARY=/usr/local/lib/libapr-1.so -DAPR_UTIL_INCLUDE_DIR=/usr/local/apr/include/apr-1 -DAPR_UTIL_LIBRARY=/usr/local/apr/lib/libaprutil-1.so -DMINIXML_INCLUDE_DIR=/usr/local/include -DMINIXML_LIBRARY=/usr/local/lib/libmxml.so
  • To specify an installation directory, add the following when running CMake: -DCMAKE_INSTALL_PREFIX=/your/install/path/usr/local/

  • If the following error is reported when you run CMake: Could not find apr-config/apr-1-config, this is because the apr-1-config file cannot be found in the default path. You can add -DAPR_CONFIG_BIN=/path/to/bin/apr-1-config to the end of the CMake command during execution. If the error “Could not find apu-config/apu-1-config” is reported, you must add: -DAPU_CONFIG_BIN=/path/to/bin/apu-1-config.

Linux example project

Based on the Alibaba Cloud OSS C-SDK example project aliyun-oss-c-sdk-demo.tar.gz. Specifically, the example oss-c-sdk-demo-specified-installation project based on OSS C-SDK and its dependent third-party libraries are all installed under the /home/your/oss/csdk directory. Other example projects based on OSS C-SDK and their dependent third-party libraries are installed under the default directory, that is, no directory is specified at the time of installation.

  • oss-c-sdk-demo-centos In Alibaba Cloud/CentOS, the OSS C-SDK example project is based in the default installation path

  • oss-c-sdk-demo-debian In Debian, the OSS C-SDK example project is based in the default installation path

  • oss-c-sdk-demo-redhat In RedHat, the OSS C-SDK example project is based in the default installation path

  • oss-c-sdk-demo-suse In SuSE, the OSS C-SDK example project is based in the default installation path

  • oss-c-sdk-demo-ubuntu In Ubuntu, the OSS C-SDK example project is based in the default installation path

  • oss-c-sdk-demo-specified-installation In Linux, the OSS C-SDK example project based in the custom installation directory

For more information on the example project, see Use Alibaba Cloud OSS C SDK in Linux.

Unzip the package and enter the project directory (oss-c-sdk-demo-xxx). run make to compile the example project. Run make clean to clear files generated from the compilation. Run ./main to run the executable program.

Note:

  • Replace the OSS_ENDPOINT, ACCESS_KEY_ID, ACCESS_KEY_SECRET and BUCKET_NAME in the example code to valid values.

  • If the OSS C-SDK and the dynamic libraries of the dependent libraries are not under the system directory, use LD_LIBRARY_PATH to specify the path at execution.

Windows

In Windows, only Win32 method is supported currently and x64 is not supported. The libraries compiled by Win32 can be used in Win32 or x64 projects.

Environment and dependency

  • The third-party libraries that OSS C-SDK (for Windows) is dependent on are consistent with those in the Linux version, that is, APR, APR-Util, curl, and mxml respectively.

  • SDK provides Visual Studio 2008 and Visual Studio 2010 projects that support Visual Studio 2008, Visual Studio 2010 and later versions respectively.

  • The SDK provides third_party that includes the header file and library file of third-party libraries that may be used (APR, APR-Util, curl, and mxml). You can compile project using header files and library files provided here to run samples and test projects.

Visual Studio 2008

  • The corresponding project files are oss_c_sdk_2008.sln and other files containing 2008.

  • The OSS C-SDK must use the stdint.h header file. By default, Visual C++ 2008 does not contain this header file. If you have not installed this header file in advance, you can rename stdint.h.bak in the third_party/include to stdint.h for use.

  • Visual Studio 2008 is not supported in versions earlier than 2.0.0 (not inclusive).

Visual Studio 2010 and later versions

  • The corresponding project files are oss_c_sdk.sln and other files not containing digits.

  • Visual Studio 2010 and later versions all contain the stdint.h header file.

  • When you use Visual Studio 2012 or a later version to open the file, the system asks whether to upgrade the project to use the latest versions of compilers and libraries. Here, the settings must be consistent with your own project: if your project uses the latest versions of the compilers and libraries, upgrade the project. Otherwise, cancel the upgrade.

Visual Studio example project

Example projects based on Visual Studio 2008/2010/2012/2013/2015 are provided. You can use Visual Studio to open the corresponding project directly, modify Endpoint/AccessKeyID/AccessKeySecret/BucketName and other configuration items and then compile and run the project. You can develop your projects based on the example project.

Note: Before running the oss-c-sdk-sample project, configure the following on Visual Studio. In Solution Explore, select the oss-c-sdk-sample project. Right-click and select Properties. In oss-c-sdk-sample Property Pages, configure Configuration Properties -> Debugging -> Environment to PATH=..\oss-c-sdk\lib\Release\;%PATH% .

For more information on the steps and common issues when using Visual Studio to compile OSS C-SDK and run example projects, see Compile and Use Alibaba Cloud OSS C-SDK in Windows.

Example project

OSS C-SDK provides rich example projects for your reference or use. You can get example projects from GitHub. The example project includes the following content:

Example file Example content
oss_put_object_sample Demonstrates Upload objects usage that includes uploading from the memory/object, uploading carrying MD5 verification, uploading carrying metadata and uploading of URL signature.
oss_get_object_sample.c Demonstrates Download objects usage, including downloading to the memory/object, downloading by range and downloading of URL signature.
oss_append_object_sample.c Demonstrates Append upload usage, including append upload from the memory/object.
oss_multipart_upload_sample.c Demonstrates Multipart upload usage, including multipart upload from the memory/object and cancellation of multipart upload.
oss_resumable_sample.c Demonstrates Resumable upload/Download in concurrency usage.
oss_head_object_sample.c Demonstrates getting Object Meta usage.
oss_list_object_sample.c Demonstrates Manage objects usage.
oss_delete_object_sample.c Demonstrates Delete objects usage, including deleting a single object and multiple objects.
oss_callback_sample.c Demonstrates Upload callback usage, including upload callback and multipart upload callback.
oss_progress_sample.c Demonstrates the progress bar usage, including upload, append upload, also the multipart upload and download.
oss_crc_sample.c Demonstrates usage for uploading and downloading Check data transmission integrity by using 64-bit CRC.
oss_image_sample.c Demonstrates Image processing usage.
Thank you! We've received your feedback.