Install the C++ SDK
Install the C++ software development kit (SDK) before you use it to perform operations in Simple Log Service. The following steps cover the SDK dependencies, the compilation of the SDK, and the library files that you then use in your own C++ program.
Prerequisites
-
Simple Log Service is activated. Activate Simple Log Service.
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.
Procedure
Install the dependencies.
NoteInstall only the packages that you need, based on your debugging requirements.
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 protobufInstall protobuf. Make sure that the protobuf and protoc versions 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/includeDownload the latest C++ SDK package, decompress it, and copy the extracted files to your project directory.
Go to the project directory and run the make command to compile the SDK.
NoteAdjust the compilation process and resolve any errors that occur. Only the main steps are described here for reference.
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.aWrite your code and run the program.
The following command links your object file with the SDK libraries to produce an executable:
g++ -o your_program your_program.o -O2 -L./lib/ -std=c++11 -lslssdk -llz4 -lcurl -lprotobuf
For more information, see C++ SDK README.