tencent cloud


Compilation Environment (Linux and Windows)

Last updated: 2021-09-26 18:00:00

    Linux (Ubuntu)


    The Ubuntu version used for demonstration in this document is v16.04.

    1. Install the necessary software
      The SDK requires CMake v3.5 or above. The CMake version installed by default is low. If compilation fails, download and install the specific version of CMake as instructed in Installation Instructions.
      $ sudo apt-get install -y build-essential make git gcc cmake
    2. Modify the configuration
      Modify the CMakeLists.txt file in the root directory of the SDK and make sure that the following options exist (with a key-authenticated device as example):
      set(BUILD_TYPE                   "release")
      set(COMPILE_TOOLS                "gcc") 
      set(PLATFORM                     "linux")
    3. Run the script for compilation
      1. Below is a complete compilation library and demo:
      2. The output library files, header files, and samples are in the output/release folder.
        After the complete compilation, if you only need to compile the demo, then run the following code:
        ./cmake_build.sh samples
    4. Enter the device information
      Enter the information of the device created on the IoT Hub platform (with a key-authenticated device as example) in device_info.json in the root directory of the SDK. Below is the sample code:
    5. Run the demo
      The demo output is in the output/release/bin folder. For example, to run the data_template_sample demo, enter ./output/release/bin/data_template_sample.


    Getting and installing Visual Studio 2019

    1. Download Visual Studio 2019 and install it. In this document, the downloaded and installed version is v16.2 Community.
    2. Select Desktop development with C++ and C++ CMake tools for Windows.

    Compilation and running

    1. Run Visual Studio, select Open a local folder, and select the downloaded SDK for C directory.

    2. Enter the information of the device created in the IoT Hub console (with a key-authenticated device as example) in device_info.json. Below is the sample code:

    3. Double-click CMakeLists.txt in the root directory and make sure that the platform is set to Windows and the compilation tool is set to MSVC in the compilation toolchain.

      # Compilation toolchain
      #set(COMPILE_TOOLS "gcc") 
      #set(PLATFORM       "linux")
      set(COMPILE_TOOLS "MSVC") 
      set(PLATFORM       "windows")
    4. Visual Studio will automatically build the CMake cache. Just wait for the build to complete.

    5. After the cache is generated, select Build > Build All.

    6. Select the corresponding demo for running, which should correspond to the user information.

    Contact Us

    Contact our sales team or business advisors to help your business.

    Technical Support

    Open a ticket if you're looking for further assistance. Our Ticket is 7x24 avaliable.

    7x24 Phone Support