Azure-Samples/ESP-Samples

PNP examples not compiling

Maldus512 opened this issue · 3 comments

I'm trying to implement a Plug and Play application for the ESP32, and I'm having a lot of problems with the various versions of the needed libraries.

Even with this repo, the compilation (of any example) fails with the following error, repeated for many source files:

FAILED: esp-idf/main/CMakeFiles/__idf_main.dir/main.c.obj 
/home/maldus/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc -DHAVE_CONFIG_H -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DUNITY_INCLUDE_CONFIG_H -DWITH_POSIX -Iconfig -I../main -I../main/inc -I../main/inc/utilities -I/home/maldus/Source/esp-idf-v4.0/components/newlib/platform_include -I/home/maldus/Source/esp-idf-v4.0/components/freertos/include -I/home/maldus/Source/esp-idf-v4.0/components/heap/include -I/home/maldus/Source/esp-idf-v4.0/components/log/include -I/home/maldus/Source/esp-idf-v4.0/components/soc/esp32/include -I/home/maldus/Source/esp-idf-v4.0/components/soc/include -I/home/maldus/Source/esp-idf-v4.0/components/esp_rom/include -I/home/maldus/Source/esp-idf-v4.0/components/esp_common/include -I/home/maldus/Source/esp-idf-v4.0/components/xtensa/include -I/home/maldus/Source/esp-idf-v4.0/components/xtensa/esp32/include -I/home/maldus/Source/esp-idf-v4.0/components/esp32/include -I/home/maldus/Source/esp-idf-v4.0/components/driver/include -I/home/maldus/Source/esp-idf-v4.0/components/esp_ringbuf/include -I/home/maldus/Source/esp-idf-v4.0/components/esp_event/include -I/home/maldus/Source/esp-idf-v4.0/components/tcpip_adapter/include -I/home/maldus/Source/esp-idf-v4.0/components/lwip/include/apps -I/home/maldus/Source/esp-idf-v4.0/components/lwip/include/apps/sntp -I/home/maldus/Source/esp-idf-v4.0/components/lwip/lwip/src/include -I/home/maldus/Source/esp-idf-v4.0/components/lwip/port/esp32/include -I/home/maldus/Source/esp-idf-v4.0/components/lwip/port/esp32/include/arch -I/home/maldus/Source/esp-idf-v4.0/components/vfs/include -I/home/maldus/Source/esp-idf-v4.0/components/esp_wifi/include -I/home/maldus/Source/esp-idf-v4.0/components/esp_wifi/esp32/include -I/home/maldus/Source/esp-idf-v4.0/components/esp_eth/include -I/home/maldus/Source/esp-idf-v4.0/components/efuse/include -I/home/maldus/Source/esp-idf-v4.0/components/efuse/esp32/include -I/home/maldus/Source/esp-idf-v4.0/components/app_trace/include -I/home/maldus/Source/esp-idf-v4.0/components/mbedtls/port/include -I/home/maldus/Source/esp-idf-v4.0/components/mbedtls/mbedtls/include -I/home/maldus/Source/esp-idf-v4.0/components/wpa_supplicant/include -I/home/maldus/Source/esp-idf-v4.0/components/wpa_supplicant/port/include -I/home/maldus/Source/esp-idf-v4.0/components/wpa_supplicant/include/esp_supplicant -I/home/maldus/Source/esp-idf-v4.0/components/bootloader_support/include -I/home/maldus/Source/esp-idf-v4.0/components/app_update/include -I/home/maldus/Source/esp-idf-v4.0/components/spi_flash/include -I/home/maldus/Source/esp-idf-v4.0/components/nvs_flash/include -I/home/maldus/Source/esp-idf-v4.0/components/pthread/include -I/home/maldus/Source/esp-idf-v4.0/components/espcoredump/include -I/home/maldus/Source/esp-idf-v4.0/components/asio/asio/asio/include -I/home/maldus/Source/esp-idf-v4.0/components/asio/port/include -I/home/maldus/Source/esp-idf-v4.0/components/coap/port/include -I/home/maldus/Source/esp-idf-v4.0/components/coap/port/include/coap -I/home/maldus/Source/esp-idf-v4.0/components/coap/libcoap/include -I/home/maldus/Source/esp-idf-v4.0/components/coap/libcoap/include/coap2 -I/home/maldus/Source/esp-idf-v4.0/components/console -I/home/maldus/Source/esp-idf-v4.0/components/nghttp/port/include -I/home/maldus/Source/esp-idf-v4.0/components/nghttp/nghttp2/lib/includes -I/home/maldus/Source/esp-idf-v4.0/components/esp-tls -I/home/maldus/Source/esp-idf-v4.0/components/esp_adc_cal/include -I/home/maldus/Source/esp-idf-v4.0/components/esp_gdbstub/include -I/home/maldus/Source/esp-idf-v4.0/components/tcp_transport/include -I/home/maldus/Source/esp-idf-v4.0/components/esp_http_client/include -I/home/maldus/Source/esp-idf-v4.0/components/esp_http_server/include -I/home/maldus/Source/esp-idf-v4.0/components/esp_https_ota/include -I/home/maldus/Source/esp-idf-v4.0/components/protobuf-c/protobuf-c -I/home/maldus/Source/esp-idf-v4.0/components/protocomm/include/common -I/home/maldus/Source/esp-idf-v4.0/components/protocomm/include/security -I/home/maldus/Source/esp-idf-v4.0/components/protocomm/include/transports -I/home/maldus/Source/esp-idf-v4.0/components/mdns/include -I/home/maldus/Source/esp-idf-v4.0/components/esp_local_ctrl/include -I/home/maldus/Source/esp-idf-v4.0/components/esp_websocket_client/include -I/home/maldus/Source/esp-idf-v4.0/components/expat/expat/expat/lib -I/home/maldus/Source/esp-idf-v4.0/components/expat/port/include -I/home/maldus/Source/esp-idf-v4.0/components/wear_levelling/include -I/home/maldus/Source/esp-idf-v4.0/components/sdmmc/include -I/home/maldus/Source/esp-idf-v4.0/components/fatfs/diskio -I/home/maldus/Source/esp-idf-v4.0/components/fatfs/vfs -I/home/maldus/Source/esp-idf-v4.0/components/fatfs/src -I/home/maldus/Source/esp-idf-v4.0/components/freemodbus/common/include -I/home/maldus/Source/esp-idf-v4.0/components/idf_test/include -I/home/maldus/Source/esp-idf-v4.0/components/jsmn/include -I/home/maldus/Source/esp-idf-v4.0/components/json/cJSON -I/home/maldus/Source/esp-idf-v4.0/components/libsodium/libsodium/src/libsodium/include -I/home/maldus/Source/esp-idf-v4.0/components/libsodium/port_include -I/home/maldus/Source/esp-idf-v4.0/components/mqtt/esp-mqtt/include -I/home/maldus/Source/esp-idf-v4.0/components/openssl/include -I/home/maldus/Source/esp-idf-v4.0/components/spiffs/include -I/home/maldus/Source/esp-idf-v4.0/components/ulp/include -I/home/maldus/Source/esp-idf-v4.0/components/unity/include -I/home/maldus/Source/esp-idf-v4.0/components/unity/unity/src -I/home/maldus/Source/esp-idf-v4.0/components/wifi_provisioning/include -I../components/esp-azure-pnp/port/inc -I../components/esp-azure-pnp/azure-iot-sdk-c/certs -I../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc -I../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility -I../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/pal/inc -I../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/pal/freertos -I../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/pal/generic -I../components/esp-azure-pnp/azure-iot-sdk-c/digitaltwin_client/inc -I../components/esp-azure-pnp/azure-iot-sdk-c/digitaltwin_client/inc/internal -I../components/esp-azure-pnp/azure-iot-sdk-c/iothub_client/inc -I../components/esp-azure-pnp/azure-iot-sdk-c/serializer/inc -I../components/esp-azure-pnp/azure-iot-sdk-c/umqtt/inc -I../components/esp-azure-pnp/azure-iot-sdk-c/umqtt/inc/azure_umqtt_c -I../components/esp-azure-pnp/azure-iot-sdk-c/deps/parson -I../components/esp-azure-pnp/azure-iot-sdk-c/deps/umock-c/inc/umock_c -I../components/esp-azure-pnp/azure-iot-sdk-c/deps/azure-macro-utils-c/inc/azure_macro_utils -I../components/esp-azure-pnp/azure-iot-sdk-c/provisioning_client/inc -I../components/esp-azure-pnp/azure-iot-sdk-c/provisioning_client/adapters -I../components/esp-azure-pnp/azure-iot-sdk-c/provisioning_client/deps/utpm/inc -I../components/i2c_devices -I../components/i2c_devices/i2c_bus/include -I../components/i2c_devices/sensor/bh1750/include -I../components/i2c_devices/sensor/hts221/include -I../components/i2c_devices/sensor/mpu6050/include -I../components/i2c_devices/sensor/mag3110/include -I../components/i2c_devices/sensor/fbm320/include -I../components/i2c_devices/ssd1306/include -I../components/i2c_devices/wm8960/include -mlongcalls -Wno-frame-address   -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -nostdlib -Wall -Werror=all -Wno-error=unused-function -Wno-error=unused-but-set-variable -Wno-error=unused-variable -Wno-error=deprecated-declarations -Wextra -Wno-unused-parameter -Wno-sign-compare -ggdb -Og -std=gnu99 -Wno-old-style-declaration -D_GNU_SOURCE -DIDF_VER=\"v4.0-beta2-695-gfe67bedee-dirty\" -DGCC_NOT_5_2_0 -DESP_PLATFORM -MD -MT esp-idf/main/CMakeFiles/__idf_main.dir/main.c.obj -MF esp-idf/main/CMakeFiles/__idf_main.dir/main.c.obj.d -o esp-idf/main/CMakeFiles/__idf_main.dir/main.c.obj   -c ../main/main.c
In file included from ../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:7,
                 from /home/maldus/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/xtensa-esp32-elf/sys-include/string.h:24,
                 from ../components/esp-azure-pnp/azure-iot-sdk-c/certs/../deps/azure-macro-utils-c/inc/azure_macro_utils/macro_utils.h:22,
                 from ../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/umock_c/umock_c_prod.h:49,
                 from ../components/esp-azure-pnp/azure-iot-sdk-c/iothub_client/inc/iothub.h:7,
                 from ../main/inc/utilities/digitaltwin_client_helper.h:18,
                 from ../main/main.c:14:
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:18:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_new);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:19:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_clone, STRING_HANDLE, handle);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:20:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_construct, const char*, psz);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:21:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_construct_n, const char*, psz, size_t, n);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:22:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_new_with_memory, const char*, memory);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:23:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_new_quoted, const char*, source);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:24:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_new_JSON, const char*, source);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:25:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_from_byte_array, const unsigned char*, source, size_t, size);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:26:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, void, STRING_delete, STRING_HANDLE, handle);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:27:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, int, STRING_concat, STRING_HANDLE, handle, const char*, s2);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:28:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, int, STRING_concat_with_STRING, STRING_HANDLE, s1, STRING_HANDLE, s2);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:29:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, int, STRING_quote, STRING_HANDLE, handle);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:30:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, int, STRING_copy, STRING_HANDLE, s1, const char*, s2);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:31:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, int, STRING_copy_n, STRING_HANDLE, s1, const char*, s2, size_t, n);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:32:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, const char*, STRING_c_str, STRING_HANDLE, handle);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:33:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, int, STRING_empty, STRING_HANDLE, handle);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:34:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, size_t, STRING_length, STRING_HANDLE, handle);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:35:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, int, STRING_compare, STRING_HANDLE, s1, STRING_HANDLE, s2);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:36:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, int, STRING_replace, STRING_HANDLE, handle, char, target, char, replace);
 ^~~~~~~~~~~~~~~~~
ninja: build stopped: subcommand failed.
ninja failed with exit code 1

The compilation process is pretty straightforward, so I have no idea what I could be doing wrong. I copied the folder esp-azure-pnp inside components and tried to build the example (azure-esp-pnp-starter) with the idf.py build command.

I have the exact same issue.
This reminds me of once I had the same problem on a project I had made myself. The issue was header files including themselves and due to the order in which they were included, one of the key headers was included last. That in turn lead to headers who relied on the aforementioned header caused compilation issues.

In file included from ../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:7,
                 from /home/robing/.espressif/tools/xtensa-esp32-elf/esp-2019r2-8.2.0/xtensa-esp32-elf/xtensa-esp32-elf/sys-include/string.h:24,
                 from ../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_macro_utils/macro_utils.h:22,
                 from ../components/esp-azure-pnp/azure-iot-sdk-c/digitaltwin_client/inc/digitaltwin_device_client_ll.h:21,
                 from ../main/inc/pnp_device.h:10,
                 from ../main/main.c:13:
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:18:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_new);
 ^~~~~~~~~~~~~~~~~
../components/esp-azure-pnp/azure-iot-sdk-c/c-utility/inc/azure_c_shared_utility/strings.h:19:1: error: unknown type name 'MU_IF'
 MOCKABLE_FUNCTION(, STRING_HANDLE, STRING_clone, STRING_HANDLE, handle);
 ^~~~~~~~~~~~~~~~~

...

The issue could be related to
'>strings.h which includes
'>> umock_c/umock_c_prod.h which includes
'>>> ../deps/azure-macro-utils-c/inc/azure_macro_utils/macro_utils.h which includes
'>>>> string.h, which is part of the xtensa build system. This in turn includes strings.h

And then we have an inclusion error of some sort. How to solve it, I have no idea, but at least this may be a clue for those who know the system.

Sorry to be late on this. we'll have a look. keep you posted

I do not reproduce the above issue.... following the exact steps described in the readme. I'm using wsl1.
FYI my config:
Toolchain path: /mnt/c/azure-iot/esp/stable/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc
Toolchain version: crosstool-ng-1.22.0-80-g6c4433a
Compiler version: 5.2.0

Perhaps interesting to look at: Azure/azure-iot-sdk-c#1177