All Products
Search
Document Center

ApsaraMQ for RocketMQ:Install the C++ dynamic library

Last Updated:Mar 10, 2026

Install the rocketmq-client-cpp dynamic library before you use the Community Edition SDK for C++ to connect to ApsaraMQ for RocketMQ.

Prerequisites

Before you begin, make sure that you have:

  • A supported operating system:

    • Linux (RPM-based): CentOS 6.8, CentOS 7.2, RHEL 6.x, or RHEL 7.x

    • Linux (Debian-based): Ubuntu 18.04

    • macOS: macOS Mojave 10.14.x

  • gcc/g++ version above 4.8

  • sudo permissions or a root account

Install the library

The rocketmq-client-cpp Community Edition provides prebuilt binaries. The following examples use version 2.0.1. For other versions, see Release Notes.

Important

The library installs to the system dynamic library directory by default. Run the following commands with sudo or as the root user.

RPM-based Linux (CentOS, RHEL)

For CentOS 7.2 and RHEL 7.x, install the rocketmq-client-cpp-2.0.1 RPM 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

For CentOS 6.8 and RHEL 6.x, use the CentOS 6 package:

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

Debian-based Linux (Ubuntu)

Download and install the .deb package:

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

macOS

Download the tarball and install the files manually:

# Download and extract the prebuilt binary
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

# Copy the shared library and headers to system paths
cp rocketmq-client-cpp/lib/* /usr/local/lib/
mkdir -p /usr/local/include/rocketmq/
cp rocketmq-client-cpp/include/* /usr/local/include/rocketmq/

# Fix the dynamic library install name for runtime linking
install_name_tool -id "@rpath/librocketmq.dylib" /usr/local/lib/librocketmq.dylib

After installation, the shared library is at /usr/local/lib/librocketmq.dylib and the headers are in /usr/local/include/rocketmq/.

Verify the installation

Confirm that the system can locate the shared library.

Linux:

ldconfig -p | grep librocketmq

If this command returns no output, refresh the shared library cache and try again:

sudo ldconfig
ldconfig -p | grep librocketmq

macOS:

ls /usr/local/lib/librocketmq.dylib

Troubleshooting

SymptomCauseSolution
librocketmq.so: cannot open shared object fileThe shared library cache has not been refreshed after installation.Run sudo ldconfig and retry.
rpm -ivh fails with a dependency errorMissing system dependencies.Install the required dependencies with yum, then retry.
dpkg -i fails with a dependency errorMissing system dependencies.Run sudo apt-get install -f to resolve dependencies, then retry.

What's next