Install the C++ SDK

Updated at:

You must install the C++ software development kit (SDK) before you can use it for operations in Simple Log Service. This topic describes how to install the C++ SDK.

Prerequisites

  • Simple Log Service is activated.

  • An AccessKey pair is created and obtained. For more information, see AccessKey pair.

    The AccessKey pair of an Alibaba Cloud account has permissions on all API operations. Using these credentials to perform operations in Simple Log Service is a high-risk operation. We recommend that you use a Resource Access Management (RAM) user to call API operations or perform routine O&M. To create a RAM user, log on to the RAM console. Make sure that the RAM user has the management permissions on Simple Log Service resources. For more information, see Create a RAM user and grant permissions.

Install the C++ SDK

  1. Install the dependencies.

    Note

    Install only the commands that you need for debugging.

    yum install gcc g++ openssl-devel perl make cmake gcc-c++ libcurl-devel -y 
    curl -O https://curl.se/download/curl-7.76.0.tar.gz && tar -xzf curl-7.76.0.tar.gz&& cd curl-7.76.0&& ./configure --prefix=/usr/local/curl --with-ssl && make -j && make install && ln -sf /usr/local/curl/bin/curl /usr/bin/curl
    yum install protobuf
  2. Install protobuf. Make sure that the versions of protobuf and protoc are the same.

    wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz
    tar zxvf protobuf-2.5.0.tar.gz
    cd protobuf-2.5.0
    ./configure  --prefix=/usr/local/protobuf
    make
    make install
    # Link protoc to the executable program directory.
     ln -s /usr/local/protobuf/bin/protoc /usr/local/bin
    # Copy the contents of the include directory to the executable program directory.
    cp -ar /usr/local/protobuf/include/google/  /usr/local/include
  3. Download the latest C++ SDK package, decompress it, and copy the files to your project directory.

  4. Go to the project directory and run the make command to compile the SDK.

    Note

    Adjust the compilation process and handle errors based on your debugging needs. The steps provided are for reference only.

    After the compilation is complete, the following files are generated. You can then use these files in your C++ program.

    lib/libslssdk.a 
    lib/libsls_logs_pb.a
    lib/liblz4.a
  5. Write your code and run the program.

    The following sample code shows how to run the program:

    g++ -o your_program your_program.o  -O2 -L./lib/ -std=c++11 -lslssdk -llz4 -lcurl -lprotobuf 

    For more information, see the C++ SDK README.