Prepare the environment

更新时间:
复制 MD 格式

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.

    Note

    Visual Studio is required only for Windows systems. These instructions use Visual Studio 2019 as an example.

Install the SDK for C++

Windows

  1. Download and extract the SDK on-premises. For the SDK download link, see release notes.

  2. From the directory where you extracted the SDK, run the following command to build the project.

    scons
  3. After the build succeeds, copy the include and lib folders from the SDK directory to your on-premises C++ project's directory.

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

    • Set Additional Include Directories

      On the project properties page, select Configuration Properties > C/C++ > General > Additional Include Directories, 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 Configuration Properties > Linker > General > Additional Library Directories, 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 Configuration Properties > Linker > Input > Additional Dependencies, 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
  5. 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.

  6. Click the 编译 button to start the build.

Linux

Note

The following instructions use CentOS as an example.

  1. Download and extract the SDK on-premises. For the SDK download link, 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 where you extracted the SDK, run the following command to build the project.

    scons
  4. After the build succeeds, copy the include and lib folders from the SDK directory to your on-premises C++ project's directory.

  5. 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.

  6. 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