Azure-Samples / iot-hub-c-raspberrypi-client-app

Application collects weather data from a BME280 sensor and sends it to IoT hub, also take actions according to cloud-to-device message, device management.
https://docs.microsoft.com/en-us/azure/iot-hub/iot-hub-raspberry-pi-kit-c-get-started
MIT License
36 stars 34 forks source link

Update setup script to align with IoT C SDK build output #41

Open jesweare opened 9 months ago

jesweare commented 9 months ago

Running sudo ./setup.sh as described in the tutorial results in an error below.

[ 16%] Building C object CMakeFiles/app.dir/main.c.o
**REDACTED**/main.c:9:10: fatal error: azure_c_shared_utility/xlogging.h: No such file or directory
    9 | #include <azure_c_shared_utility/xlogging.h>
      |          ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
compilation terminated.
make[2]: *** [CMakeFiles/app.dir/build.make:76: CMakeFiles/app.dir/main.c.o] Error 1
make[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/app.dir/all] Error 2
make: *** [Makefile:91: all] Error 2

This occurs as setup.sh assumes the directory {build_root}/cmake/iotsdk_linux to be the build output of IoT C SDK. It was so in the past (example), but the current output is {build_root}/cmake instead (example). Due to this mismatch installation of IoT C SDK ends midway, leaving no actual library for the application code to reference.

+ build_folder=/home/***/Source/azure-iot-sdk-c/cmake
...
~/Source/azure-iot-sdk-c/build_all/linux
sh: 14: cd: can't cd to ../../cmake/iotsdk_linux
make: *** No targets specified and no makefile found.  Stop.
make: *** No rule to make target 'install'.  Stop.
...

With the proposed change, setup.sh would reference the correct directory, thereby installing the SDK and succeeding in building the app.