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:
Python 3.5 or later (required by SCons)
SCons build tool
(Windows only) Visual Studio 2015 or later
The examples in this topic use Visual Studio 2019. Other versions may have slightly different UI layouts.
Install the SDK
Windows
Download the C++ SDK package and decompress it to a local directory.
In the SDK directory, run the following command to compile your C++ project:
sconsCopy the include and lib folders from the SDK directory to your C++ project directory.
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 . Set Additional Include Directories to the path of the include folder you copied in Step 3.

b. Set the library path
Go to . 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

c. Set the linker dependencies
Go to . 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
Copy the sample code into your project file and update the parameter values based on the inline comments.
Click the
icon to compile the project.NoteIf 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
The following steps use CentOS as an example. Adjust package manager commands for other distributions (for example, use apt-get on Ubuntu/Debian).
Download the C++ SDK package and decompress it to a local directory.
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)In the SDK directory, run the following command to compile your C++ project:
sconsCopy the include and lib folders from the SDK directory to your C++ project directory.
Copy the sample code into your project file and update the parameter values based on the inline comments.
Compile the project. Replace
producer.cppwith the name of your source file:g++ producer.cpp -o producer lib/libmqcpp.a -I include/ -lcurl -lcryptoNoteIf you get an error such as
cannot find -lcurlorcannot find -lcrypto, verify thatlibcurl-develandopenssl-develare installed (Step 2). On some distributions, runldconfigto refresh the shared library cache.
What's next
For complete examples of publishing and subscribing to messages, see Sample code.