Before you use the SDK for C++ to publish and subscribe to messages, prepare the environment by following the instructions provided in this topic.
Environment requirements
- SCons is installed. For more information, visit the official website of SCons.
- Before you can use SCons, make sure that Python 3.5 or later is installed. For more information, visit the official website of Python.
- Visual Studio 2015 or later is installed. For more information, see Visual Studio. Note Visual Studio is required only in Windows OS. In this topic, Visual Studio 2019 is used in the example.
Install the SDK for C++
Windows OS
- Download the SDK for C++ to your on-premises machine and decompress the package. For more information about SDK download links, see Release notes.
- In the directory to which the SDK is downloaded, run the following command to compile your C++ project:
scons
- After the project is compiled, copy the include and lib folders in the SDK directory to the C++ project directory that you create on your on-premises machine.
- Configure project properties in Visual Studio. Right-click your project and select Properties.
- Set the Additional Include Directories property
In the Property Pages dialog box of your project, choose Additional Include Directories to the path of the include folder that is copied in Step 3.
in the left-side navigation pane. On the right, set - Set the Additional Library Directories property
In the Property Pages dialog box of your project, choose Additional Library Directories to the path of the lib folder that is copied in Step 3 and the path of the lib\windows\ {Platform directory} folder. Configure {Platform directory} based on the OS that you use. If you use a 64-bit OS, set this parameter to AMD64. If you use a 32-bit OS, set this parameter to I386.
in the left-side navigation pane. On the right, set - Set the Additional Dependencies propertyIn the Property Pages dialog box of your project, choose Additional Dependenciesin the left-side navigation pane. On the right, add the following content to the field:
mqcpp.lib libcurl.lib libcurl_debug.lib libeay32MT.lib libeay32MTd.lib ssleay32MT.lib ssleay32MTd.lib DbgHelp.lib User32.lib GDI32.lib Advapi32.lib
- Set the Additional Include Directories property
- Copy the sample code to the project file, change the parameter values based on the comments in the code, and then save the changes. For more information about the sample code, see Sample code.
- Click the
icon to compile the project.
Linux OS
Note In the following operations, CentOS is used in the example.
- Download the SDK for C++ to your on-premises machine and decompress the package. For more information about SDK download links, see Release notes.
- Run the following commands to install the
libcurl-devel
andopenssl-devel
libraries:yum install libcurl-devel
yum install openssl-devel
- In the directory to which the SDK is downloaded, run the following command to compile your C++ project:
scons
- After the project is compiled, copy the include and lib folders in the SDK directory to the C++ project directory that you create on your on-premises machine.
- Copy the sample code to the project file on your on-premises machine, change the parameter values based on the comments in the code, and then save the changes. For more information about the sample code, see Sample code.
- Run the following command to compile the project:
# Replace producer.cpp with the name of the project file that you create on your on-premises machine. g++ producer.cpp -o producer lib/libmqcpp.a -I include/ -lcurl -lcrypto