c++ – Azure DPS: sample paho_iot_provisioning_sample in azure-sdk-for-c failed to execute the command cmake -DTRANSPORT_PAHO=ON

i am following a sample called paho_iot_provisioning_sample (here is the doc: github.com/Azure/azure-sdk-for-c/blob/main/sdk/samples/iot/README.md) to implement Azure DPS to generate devices in Azure IoT hub.

I managed to generate the certificate X.509 and i need to build and run the sample but i am blocked (github.com/Azure/azure-sdk-for-c/blob/main/sdk/samples/iot/README.md#build-and-run-the-sample).

The prerequisites from the doc is:

Have Microsoft [vcpkg](https://github.com/mimqtcrosoft/vcpkg) package manager and [Eclipse Paho MQTT C client](https://www.eclipse.org/paho/) installed.

I managed to install vcpkg but the installation of eclipse paho mqtt C client is more complicated.

This command cmake -DTRANSPORT_PAHO=ON .. output an error:

CMake Error at sdk/samples/iot/CMakeLists.txt:16 (find_package):
  By not providing "Findeclipse-paho-mqtt-c.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "eclipse-paho-mqtt-c", but CMake did not find one.

  Could not find a package configuration file provided by
  "eclipse-paho-mqtt-c" with any of the following names:


  Add the installation prefix of "eclipse-paho-mqtt-c" to CMAKE_PREFIX_PATH
  or set "eclipse-paho-mqtt-c_DIR" to a directory containing one of the above
  files.  If "eclipse-paho-mqtt-c" provides a separate development package or
  SDK, be sure it has been installed.

I found the eclipse-paho-mqtt-cConfig.cmake file and set the new location in CMakeLists.txt located in azure-sdk-for-c/sdk/samples/iot like so:

set(eclipse-paho-mqtt-c_DIR "C:/Users/Azure-iothub-dps/src/CMakeFiles/Export/lib/cmake/eclipse-paho-mqtt-c")
but i got a new error:

CMake Error at C:/Users/Azure-iothub-dps/src/CMakeFiles/Export/lib/cmake/eclipse-paho-mqtt-c/eclipse-paho-mqtt-cConfig.cmake:87 (message):
  The imported target "eclipse-paho-mqtt-c::paho-mqtt3c" references the file


  but this file does not exist.  Possible reasons include:

  * The file was deleted, renamed, or moved to another location.

  * An install or uninstall procedure did not complete successfully.

  * The installation package was faulty and contained

but not all the files it references.

and it can not find the file libpaho-mqtt3c.dll.a anywhere. Any idea ?

Set up:

Read more here: Source link