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

  1. Download the SDK for C++ to your on-premises machine and decompress the package. For more information about SDK download links, see Release notes.
  2. In the directory to which the SDK is downloaded, run the following command to compile your C++ project:
    scons
  3. 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.
  4. 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 Configuration Properties > C/C++ > General in the left-side navigation pane. On the right, set Additional Include Directories to the path of the include folder that is copied in Step 3.

      Additional Include Directories
    • Set the Additional Library Directories property

      In the Property Pages dialog box of your project, choose Configuration Properties > Linker > General in the left-side navigation pane. On the right, set 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.

      Additional Library Directories
    • Set the Additional Dependencies property
      In the Property Pages dialog box of your project, choose Configuration Properties > Linker > Input in the left-side navigation pane. On the right, add the following content to the field: 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 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.
  6. Click the Compilation icon to compile the project.

Linux OS

Note In the following operations, CentOS is used in the example.
  1. Download the SDK for C++ to your on-premises machine and decompress the package. For more information about SDK download links, see Release notes.
  2. Run the following commands to install the libcurl-devel and openssl-devel libraries:
    yum install libcurl-devel
    yum install openssl-devel
  3. In the directory to which the SDK is downloaded, run the following command to compile your C++ project:
    scons
  4. 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.
  5. 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.
  6. 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