All Products
Search
Document Center

ApsaraMQ for RocketMQ:Set up the C++ SDK environment

Last Updated:Mar 11, 2026

Install the ApsaraMQ for RocketMQ C++ SDK and configure your project on Windows or Linux to publish and subscribe to messages.

Prerequisites

Before you begin, make sure that you have:

Note

The examples in this topic use Visual Studio 2019. Other versions may have slightly different UI layouts.

Install the SDK

Windows

  1. Download the C++ SDK package and decompress it to a local directory.

  2. In the SDK directory, run the following command to compile your C++ project:

    scons
  3. Copy the include and lib folders from the SDK directory to your C++ project directory.

  4. Configure Visual Studio project properties. Right-click your project and select Properties.

    Complete the following configurations in the Property Pages dialog box.

    • a. Set the include path

      Go to Configuration Properties > C/C++ > General. Set Additional Include Directories to the path of the include folder you copied in Step 3.

      Additional Include Directories

    • b. Set the library path

      Go to Configuration Properties > Linker > General. Set Additional Library Directories to both of the following paths:

      • The lib folder you copied in Step 3

      • The lib\windows\<Platform> folder, where <Platform> is AMD64 for 64-bit systems or I386 for 32-bit systems

      Additional Library Directories

    • c. Set the linker dependencies

      Go to Configuration Properties > Linker > Input. Add the following libraries to Additional Dependencies:

      mqcpp.lib
      libcurl.lib
      libcurl_debug.lib
      libeay32MT.lib
      libeay32MTd.lib
      ssleay32MT.lib
      ssleay32MTd.lib
      DbgHelp.lib
      User32.lib
      GDI32.lib
      Advapi32.lib

      Additional Dependencies

  5. Copy the sample code into your project file and update the parameter values based on the inline comments.

  6. Click the Compilation icon to compile the project.

    Note

    If you get linker errors such as unresolved external symbol, verify that the Additional Library Directories and Additional Dependencies paths are correct and that you are building for the matching platform (x64 or x86).

Linux

Note

The following steps use CentOS as an example. Adjust package manager commands for other distributions (for example, use apt-get on Ubuntu/Debian).

  1. Download the C++ SDK package and decompress it to a local directory.

  2. Install the required dependencies:

    yum install libcurl-devel    # HTTP client library (required for SDK networking)
    yum install openssl-devel    # TLS/SSL library (required for secure connections)
  3. In the SDK directory, run the following command to compile your C++ project:

    scons
  4. Copy the include and lib folders from the SDK directory to your C++ project directory.

  5. Copy the sample code into your project file and update the parameter values based on the inline comments.

  6. Compile the project. Replace producer.cpp with the name of your source file:

    g++ producer.cpp -o producer   lib/libmqcpp.a -I include/ -lcurl -lcrypto
    Note

    If you get an error such as cannot find -lcurl or cannot find -lcrypto, verify that libcurl-devel and openssl-devel are installed (Step 2). On some distributions, run ldconfig to refresh the shared library cache.

What's next

For complete examples of publishing and subscribing to messages, see Sample code.