All Products
Search
Document Center

ApsaraMQ for RocketMQ:Install the C++ dynamic library

Last Updated:Mar 15, 2024

Before you use the SDK for C++ to connect to Alibaba Cloud ApsaraMQ for RocketMQ to send and receive messages, you must follow the steps provided in this topic to install the C++ dynamic library.

Important
  • We recommend that you use the latest RocketMQ 5.x SDKs. These SDKs are fully compatible with ApsaraMQ for RocketMQ 5.x brokers and provides more functions and enhanced features. For more information, see Release notes.

  • Alibaba Cloud only maintains RocketMQ 4.x, 3.x, and TCP client SDKs. We recommend that you use them only for existing business.

Before you start

Make sure that your operating system meets the following requirements:

  • Linux: CentOS 6.8, CentOS 7.2, RHEL 6.x, or RHEL 7.x

  • Darwin: macOS Mojave 10.14.x

  • Debian: Ubuntu 18.04

Note

This topic does not provide instructions for installing the GCC environment. Make sure that the version of the GCC or G++ environment on your on-premises machine is 4.8 or later.

Install the C++ dynamic library

Important

By default, the C++ dynamic library is installed in the dynamic library directory of the system. Make sure that the current account has the sudo permission. You can also use the root account to install the C++ dynamic library.

The C++ dynamic library provides the binary release. This allows you to directly obtain open source code. For more information, see Release notes. This topic describes how to use rocketmq-client-cpp-2.0.1 to install the C++ dynamic library in different operating systems.

  • CentOS 7.2 and RHEL 7.x

    By default, CentOS supports Red-Hat Package Manager (RPM). The name of the RPM package is rocketmq-client-cpp-2.0.1. You can run the following rpm command to install the package.

    rpm -ivh https://github.com/apache/rocketmq-client-cpp/releases/download/2.0.1/rocketmq-client-cpp-2.0.1-centos7.x86_64.rpm

  • CentOS 6.8 and RHEL 6.x

    The procedure to install the dynamic library in CentOS 6.8 is the same as that in CentOS 7. However, CentOS 6.8 uses a different RPM package. You can run the following command to install the C++ dynamic library:

    rpm -ivh https://github.com/apache/rocketmq-client-cpp/releases/download/2.0.1/rocketmq-client-cpp-2.0.1-centos6.x86_64.rpm

  • macOS Mojave 10.14

    macOS does not provide a package management tool. You can run the following command to manually install the C++ dynamic library:

    mkdir cppsdk
    cd cppsdk
    wget https://github.com/apache/rocketmq-client-cpp/releases/download/2.0.1/rocketmq-client-cpp-2.0.1-bin-release-darwin.tar.gz
    tar -xzf rocketmq-client-cpp-2.0.1-bin-release-darwin.tar.gz
    cp rocketmq-client-cpp/lib/* /usr/local/lib/
    mkdir -p /usr/local/include/rocketmq/
    cp rocketmq-client-cpp/include/* /usr/local/include/rocketmq/
    install_name_tool -id "@rpath/librocketmq.dylib" /usr/local/lib/librocketmq.dylib
  • Ubuntu 18.04

    The kernel of Ubuntu 18.04 is Debian, which uses dpkg as its default package manager. The package name is rocketmq-client-cpp-2.0.1.amd64.deb. You can run the following command to install the C++ dynamic library:

    wget https://github.com/apache/rocketmq-client-cpp/releases/download/2.0.1/rocketmq-client-cpp-2.0.1.amd64.deb
    dpkg -i rocketmq-client-cpp-2.0.1.amd64.deb

After you perform the preceding operations, the C++ dynamic library is installed.

What to do next

Sample code