To use the SDK for C++ to publish and subscribe to messages, prepare your environment.
Prerequisites
-
Install SCons. For more information, see Install SCons.
-
SCons requires Python 3.5 or later. For more information, see Install Python.
-
Install Visual Studio 2015 or later. For more information, see Install Visual Studio.
NoteVisual Studio is required only for Windows systems. These instructions use Visual Studio 2019 as an example.
Install the SDK for C++
Windows
-
Download and extract the SDK on-premises. For the SDK download link, see release notes.
-
From the directory where you extracted the SDK, run the following command to build the project.
scons -
After the build succeeds, copy the include and lib folders from the SDK directory to your on-premises C++ project's directory.
-
Configure the project properties in Visual Studio. Right-click the project and select Properties.
-
Set Additional Include Directories
On the project properties page, select , and set Additional Include Directories to the path of the include folder that you copied in Step 3.
-
Set Additional Library Directories
On the Project Properties page, select , and set Additional Library Directories to the path of the lib folder that you copied in Step 3 and the path of the lib\windows\{Platform Directory} folder. The {Platform Directory} placeholder depends on your operating system: use AMD64 for a 64-bit OS and I386 for a 32-bit OS.
-
Set Additional Dependencies
In the project properties page, select , and add the following content 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, modify the parameters as instructed in the comments, and save the file. To download the sample code, see sample code.
-
Click the
button to start the build.
Linux
The following instructions use CentOS as an example.
-
Download and extract the SDK on-premises. For the SDK download link, see release notes.
-
Run the following commands to install the
libcurl-develandopenssl-devellibraries:yum install libcurl-develyum install openssl-devel -
In the directory where you extracted the SDK, run the following command to build the project.
scons -
After the build succeeds, copy the include and lib folders from the SDK directory to your on-premises C++ project's directory.
-
Copy the sample code into your on-premises project, modify the parameters as instructed in the comments, and save the file. To download the sample code, see sample code.
-
Run the following command to compile the project.
# Replace producer.cpp with your project's filename. g++ producer.cpp -o producer lib/libmqcpp.a -I include/ -lcurl -lcrypto