Closed GonzalezAnguita closed 4 years ago
In your file azure-test/CMakeLists.txt, can you try by inserting the keyword ENV in this line as below
set (EXTRA_COMPONENT_DIRS "$ENV{ESP_PATH}/esp-azure/port")
Thanks for your response @shahpiyushv
Checked the logs again and found a variable warning
CMake Warning (dev) at CMakeLists.txt:6 (set):
uninitialized variable 'ESP_PATH'
This warning is for project developers. Use -Wno-dev to suppress it.
Add ENV to the variable, fixes just the variable warning.
I tried the following and in all cases I've got the same original issue.
Also deleted the build directory just in case there were some cached files, nothing.
From azure-test/CMakeLists.txt I changed the line
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
with
include($ENV{MDF_PATH}/project.cmake)
because I was getting that the MDF library mcommon was not being found. Changing the previous line did not work until I moved the line set (EXTRA_COMPONENT_DIRS "$ENV{ESP_AZURE}/port") to the file azure-test/components/azure_mqtt_handler/CMakeLists.txt and the error message changed to the following
Checking Python dependencies...
Python requirements from /Users/joseto/esp/esp-mdf/esp-idf/requirements.txt are satisfied.
Running ninja in directory /Users/joseto/esp/projects/iothub_client_sample_mqtt/build
Executing "ninja all"...
[0/1] Re-running CMake...
-- Building empty aws_iot component due to configuration
-- Building empty aliyun iot sdk component due to configuration
-- Building empty aws_iot component due to configuration
-- Component names: soc log heap xtensa-debug-module app_trace freertos vfs newlib esp_ringbuf driver esp_event ethernet lwip tcpip_adapter partition_table app_update spi_flash mbedtls micro-ecc bootloader_support nvs_flash pthread smartconfig_ack wpa_supplicant esp32 cxx nghttp esp-tls tcp_transport esp_http_client json mcommon azure_mqtt_handler main esp-aliyun miniz mwifi mespnow console mdns esp_http_server mupgrade bt mconfig mlink maliyun_linkkit wear_levelling sdmmc fatfs spiffs mdebug asio jsmn aws_iot bootloader coap esp_adc_cal esp_https_ota esptool_py expat freemodbus idf_test libsodium mqtt openssl protobuf-c protocomm ulp wifi_provisioning
-- Component paths: /Users/joseto/esp/esp-mdf/esp-idf/components/soc;/Users/joseto/esp/esp-mdf/esp-idf/components/log;/Users/joseto/esp/esp-mdf/esp-idf/components/heap;/Users/joseto/esp/esp-mdf/esp-idf/components/xtensa-debug-module;/Users/joseto/esp/esp-mdf/esp-idf/components/app_trace;/Users/joseto/esp/esp-mdf/esp-idf/components/freertos;/Users/joseto/esp/esp-mdf/esp-idf/components/vfs;/Users/joseto/esp/esp-mdf/esp-idf/components/newlib;/Users/joseto/esp/esp-mdf/esp-idf/components/esp_ringbuf;/Users/joseto/esp/esp-mdf/esp-idf/components/driver;/Users/joseto/esp/esp-mdf/esp-idf/components/esp_event;/Users/joseto/esp/esp-mdf/esp-idf/components/ethernet;/Users/joseto/esp/esp-mdf/esp-idf/components/lwip;/Users/joseto/esp/esp-mdf/esp-idf/components/tcpip_adapter;/Users/joseto/esp/esp-mdf/esp-idf/components/partition_table;/Users/joseto/esp/esp-mdf/esp-idf/components/app_update;/Users/joseto/esp/esp-mdf/esp-idf/components/spi_flash;/Users/joseto/esp/esp-mdf/esp-idf/components/mbedtls;/Users/joseto/esp/esp-mdf/esp-idf/components/micro-ecc;/Users/joseto/esp/esp-mdf/esp-idf/components/bootloader_support;/Users/joseto/esp/esp-mdf/esp-idf/components/nvs_flash;/Users/joseto/esp/esp-mdf/esp-idf/components/pthread;/Users/joseto/esp/esp-mdf/esp-idf/components/smartconfig_ack;/Users/joseto/esp/esp-mdf/esp-idf/components/wpa_supplicant;/Users/joseto/esp/esp-mdf/esp-idf/components/esp32;/Users/joseto/esp/esp-mdf/esp-idf/components/cxx;/Users/joseto/esp/esp-mdf/esp-idf/components/nghttp;/Users/joseto/esp/esp-mdf/esp-idf/components/esp-tls;/Users/joseto/esp/esp-mdf/esp-idf/components/tcp_transport;/Users/joseto/esp/esp-mdf/esp-idf/components/esp_http_client;/Users/joseto/esp/esp-mdf/esp-idf/components/json;/Users/joseto/esp/esp-mdf/components/mcommon;/Users/joseto/esp/projects/iothub_client_sample_mqtt/components/azure_mqtt_handler;/Users/joseto/esp/projects/iothub_client_sample_mqtt/main;/Users/joseto/esp/esp-mdf/components/third_party/esp-aliyun;/Users/joseto/esp/esp-mdf/components/third_party/miniz;/Users/joseto/esp/esp-mdf/components/mwifi;/Users/joseto/esp/esp-mdf/components/mespnow;/Users/joseto/esp/esp-mdf/esp-idf/components/console;/Users/joseto/esp/esp-mdf/esp-idf/components/mdns;/Users/joseto/esp/esp-mdf/esp-idf/components/esp_http_server;/Users/joseto/esp/esp-mdf/components/mupgrade;/Users/joseto/esp/esp-mdf/esp-idf/components/bt;/Users/joseto/esp/esp-mdf/components/mconfig;/Users/joseto/esp/esp-mdf/components/mlink;/Users/joseto/esp/esp-mdf/components/maliyun_linkkit;/Users/joseto/esp/esp-mdf/esp-idf/components/wear_levelling;/Users/joseto/esp/esp-mdf/esp-idf/components/sdmmc;/Users/joseto/esp/esp-mdf/esp-idf/components/fatfs;/Users/joseto/esp/esp-mdf/esp-idf/components/spiffs;/Users/joseto/esp/esp-mdf/components/mdebug;/Users/joseto/esp/esp-mdf/esp-idf/components/asio;/Users/joseto/esp/esp-mdf/esp-idf/components/jsmn;/Users/joseto/esp/esp-mdf/esp-idf/components/aws_iot;/Users/joseto/esp/esp-mdf/esp-idf/components/bootloader;/Users/joseto/esp/esp-mdf/esp-idf/components/coap;/Users/joseto/esp/esp-mdf/esp-idf/components/esp_adc_cal;/Users/joseto/esp/esp-mdf/esp-idf/components/esp_https_ota;/Users/joseto/esp/esp-mdf/esp-idf/components/esptool_py;/Users/joseto/esp/esp-mdf/esp-idf/components/expat;/Users/joseto/esp/esp-mdf/esp-idf/components/freemodbus;/Users/joseto/esp/esp-mdf/esp-idf/components/idf_test;/Users/joseto/esp/esp-mdf/esp-idf/components/libsodium;/Users/joseto/esp/esp-mdf/esp-idf/components/mqtt;/Users/joseto/esp/esp-mdf/esp-idf/components/openssl;/Users/joseto/esp/esp-mdf/esp-idf/components/protobuf-c;/Users/joseto/esp/esp-mdf/esp-idf/components/protocomm;/Users/joseto/esp/esp-mdf/esp-idf/components/ulp;/Users/joseto/esp/esp-mdf/esp-idf/components/wifi_provisioning
-- Adding linker script /Users/joseto/esp/projects/iothub_client_sample_mqtt/build/esp32/esp32_out.ld
-- Adding linker script /Users/joseto/esp/esp-mdf/esp-idf/components/esp32/ld/esp32.common.ld
-- Adding linker script /Users/joseto/esp/esp-mdf/esp-idf/components/esp32/ld/esp32.rom.ld
-- Adding linker script /Users/joseto/esp/esp-mdf/esp-idf/components/esp32/ld/esp32.peripherals.ld
-- Adding linker script /Users/joseto/esp/esp-mdf/esp-idf/components/esp32/ld/esp32.rom.libgcc.ld
-- Adding linker script /Users/joseto/esp/esp-mdf/esp-idf/components/esp32/ld/esp32.rom.spiram_incompatible_fns.ld
-- Building empty aliyun iot sdk component due to configuration
-- Building empty aws_iot component due to configuration
-- Building empty aws_iot component due to configuration
-- Component libraries: soc;log;heap;xtensa-debug-module;app_trace;freertos;vfs;newlib;esp_ringbuf;driver;esp_event;ethernet;lwip;tcpip_adapter;app_update;spi_flash;mbedtls;micro-ecc;bootloader_support;nvs_flash;pthread;smartconfig_ack;wpa_supplicant;esp32;cxx;nghttp;esp-tls;tcp_transport;esp_http_client;json;mcommon;azure_mqtt_handler;main;esp-aliyun;miniz;mwifi;mespnow;console;mdns;esp_http_server;mupgrade;bt;mconfig;mlink;maliyun_linkkit;wear_levelling;sdmmc;fatfs;spiffs;mdebug;asio;jsmn;aws_iot;coap;esp_adc_cal;esp_https_ota;expat;freemodbus;idf_test;libsodium;mqtt;openssl;protobuf-c;protocomm;ulp;wifi_provisioning
-- Configuring done
-- Generating done
-- Build files have been written to: /Users/joseto/esp/projects/iothub_client_sample_mqtt/build
[1/291] Building C object azure_mqtt_handler/CMakeFiles/azure_mqtt_handler.dir/azure_mqtt_handler.c.obj
FAILED: azure_mqtt_handler/CMakeFiles/azure_mqtt_handler.dir/azure_mqtt_handler.c.obj
/Users/joseto/esp/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc -DESP_PLATFORM -DGCC_NOT_5_2_0=1 -DHAVE_CONFIG_H -DIDF_VER=\"v3.2.2-42-g4a9f33944\" -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DMDF_VER=\"-128-NOTFOUND\" -Iconfig -I/Users/joseto/esp/esp-mdf/components/mcommon/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/spi_flash/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/esp_http_client/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/nghttp/port/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/nghttp/nghttp2/lib/includes -I/Users/joseto/esp/esp-mdf/esp-idf/components/nvs_flash/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/mbedtls/port/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/mbedtls/mbedtls/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/lwip/include/apps -I/Users/joseto/esp/esp-mdf/esp-idf/components/lwip/lwip/src/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/lwip/port/esp32/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/lwip/port/esp32/include/arch -I/Users/joseto/esp/esp-mdf/esp-idf/components/lwip/include_compat -I/Users/joseto/esp/esp-mdf/esp-idf/components/vfs/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/json/cJSON -I/Users/joseto/esp/esp-mdf/esp-idf/components/esp32/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/driver/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/esp_ringbuf/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/tcpip_adapter/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/esp_event/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/log/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/newlib/platform_include -I/Users/joseto/esp/esp-mdf/esp-idf/components/newlib/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/freertos/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/app_trace/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/heap/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/soc/esp32/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/soc/include -Og -std=gnu99 -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -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 -Wno-old-style-declaration -ggdb -MD -MT azure_mqtt_handler/CMakeFiles/azure_mqtt_handler.dir/azure_mqtt_handler.c.obj -MF azure_mqtt_handler/CMakeFiles/azure_mqtt_handler.dir/azure_mqtt_handler.c.obj.d -o azure_mqtt_handler/CMakeFiles/azure_mqtt_handler.dir/azure_mqtt_handler.c.obj -c ../components/azure_mqtt_handler/azure_mqtt_handler.c
../components/azure_mqtt_handler/azure_mqtt_handler.c:4:27: fatal error: iothub_client.h: No such file or directory
compilation terminated.
[2/291] Building C object main/CMakeFiles/main.dir/main.c.obj
FAILED: main/CMakeFiles/main.dir/main.c.obj
/Users/joseto/esp/xtensa-esp32-elf/bin/xtensa-esp32-elf-gcc -DESP_PLATFORM -DGCC_NOT_5_2_0=1 -DHAVE_CONFIG_H -DIDF_VER=\"v3.2.2-42-g4a9f33944\" -DMBEDTLS_CONFIG_FILE=\"mbedtls/esp_config.h\" -DMDF_VER=\"-128-NOTFOUND\" -Iconfig -I../main -I/Users/joseto/esp/esp-mdf/components/mcommon/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/spi_flash/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/esp_http_client/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/nghttp/port/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/nghttp/nghttp2/lib/includes -I/Users/joseto/esp/esp-mdf/esp-idf/components/nvs_flash/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/mbedtls/port/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/mbedtls/mbedtls/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/lwip/include/apps -I/Users/joseto/esp/esp-mdf/esp-idf/components/lwip/lwip/src/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/lwip/port/esp32/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/lwip/port/esp32/include/arch -I/Users/joseto/esp/esp-mdf/esp-idf/components/lwip/include_compat -I/Users/joseto/esp/esp-mdf/esp-idf/components/vfs/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/json/cJSON -I/Users/joseto/esp/esp-mdf/esp-idf/components/esp32/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/driver/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/esp_ringbuf/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/tcpip_adapter/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/esp_event/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/log/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/newlib/platform_include -I/Users/joseto/esp/esp-mdf/esp-idf/components/newlib/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/freertos/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/app_trace/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/heap/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/soc/esp32/include -I/Users/joseto/esp/esp-mdf/esp-idf/components/soc/include -Og -std=gnu99 -ffunction-sections -fdata-sections -fstrict-volatile-bitfields -mlongcalls -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 -Wno-old-style-declaration -ggdb -MD -MT main/CMakeFiles/main.dir/main.c.obj -MF main/CMakeFiles/main.dir/main.c.obj.d -o main/CMakeFiles/main.dir/main.c.obj -c ../main/main.c
../main/main.c:1:32: fatal error: azure_mqtt_handler.h: No such file or directory
compilation terminated.
[3/291] Performing build step for 'bootloader'
ninja: no work to do.
[10/289] Building C object miniz/CMakeFiles/miniz.dir/miniz_tdef.c.obj
ninja: build stopped: subcommand failed.
ninja failed with exit code 1
I can see two lines standing out here
[196/745] Building C object azure_mqtt_handler/CMakeFiles/azure_mqtt_handler.dir/azure_mqtt_handler.c.obj
( . . . )
../components/azure_mqtt_handler/azure_mqtt_handler.c:4:27: fatal error: iothub_client.h: No such file or directory
and
[197/745] Building C object main/CMakeFiles/main.dir/main.c.obj
( . . . )
../main/main.c:1:32: fatal error: azure_mqtt_handler.h: No such file or directory
@GonzalezAnguita , this may sound naive, but have you indeed set the ESP_PATH using export ESP_PATH
command so that it points to the PATH you mentioned where you have cloned esp-azure (ESP_PATH/esp-azure)? Ideally, this single change should have been enough.
@shahpiyushv yes, all ENV variables are correctly set. It’s weird since I am using the same in the examples and those work perfectly. The difference is in the component folder structure
I'm experiencing something similar to what @GonzalezAnguita is experiencing, but with an even simpler project structure.
esp-project
|--> main
| +--> main.c
| +--> CMakeLists.txt
|--> CMakeLists.txt
|--> sdkconfig
esp-project/CMakeLists.txt
cmake_minimum_required(VERSION 3.5)
include($ENV{IDF_PATH}/tools/cmake/project.cmake)
set(EXTRA_COMPONENT_DIRS "${PROJECT_DIR}/.../esp-azure/port")
project(esp-project)
project/main/CMakeLists.txt
idf_component_register(
SRCS "main.c"
INCLUDE_DIRS ""
)
project/main/main.c
#include "iothub.h"
#include "stdio.h"
void app_main(void)
{
printf("Hello World.\n");
}
When compiling the following error message occurs:
../main/main.c:1:10: fatal error: iothub.h: No such file or directory
#include "iothub.h"
^~~~~~~~~~
The project compiles fine when I remove #include "iothub.h"
from main.c. Changing set(EXTRA_COMPONENT_DIRS "${PROJECT_DIR}/.../esp-azure/port")
or removing it doesn't do anything as well.
After some experimenting, I realized some issues, the first one is that if you import the azure sdk as this
set (EXTRA_COMPONENT_DIRS "$ENV{ESP_PATH}/esp-azure/port")
it will cause issues with the project components
directory so you must use
set (EXTRA_COMPONENT_DIRS "${EXTRA_COMPONENT_DIRS} $ENV{ESP_PATH}/esp-azure/port")
Second one is that it seems that you can't import the SDK using the previous line from inside a COMPONENT_DIR
trying to do so, will result in errors like No such file or directory
. Also the import doesn't propagate into the components
directory so you can't import it from the project/CMakeLists.txt
file trying to use it in a component.
Disclaimer: is not the cleanest solution but works
So how to be able to use the SDK and also custom components?
set (EXTRA_COMPONENT_DIRS "${EXTRA_COMPONENT_DIRS} $ENV{ESP_PATH}/esp-azure/port")
main
directory called azure_handler
for example. And inside place azure_handler.h
and azure_handler.c
.project/main/CMakeLists.txt
should be something like this
set(COMPONENT_ADD_INCLUDEDIRS "azure_handler")
set(COMPONENT_SRCS "azure_handler/azure_handler.c" "main.c")
register_component()
Hope this helps someone.
JT
PS: If you have a better and cleanest solution please take the time to share it. Thanks
@GonzalezAnguita , keeping rest everything the same as you already had i.e. esp-azure under ESP_PATH and this structure
azure_test
|--> components
| +--> azure_mqtt_handler
| +--> azure_mqtt_handler.c
| +--> CMakeLists.txt
| +--> include
| +--> azure_mqtt_handler.h
|--> main
| +--> main.c
| +--> CMakeLists.txt
| +--> Kconfig.projbuild
|--> CMakeLists.txt
can you try setting extra components dirs as below and check?
set (EXTRA_COMPONENT_DIRS "$ENV{ESP_PATH}/port" "${CMAKE_CURRENT_BINARY_DIR}/components")
@shahpiyushv tried that and the component complains
../components/azure_mqtt_handler/azure_mqtt_handler.c:4:27: fatal error: iothub_client.h: No such file or directory
I'm not an advanced user of this sdk but are we looking at an issue where compiler can't find header files? In Makefile I have this:
# EXTRA_COMPONENT_DIRS += $(PROJECT_PATH)/../../../esp-azure
EXTRA_COMPONENT_DIRS += $(AZURE_PATH)
I never copied any components from azure to my project folder. Instead, I defined an additional env AZURE_PATH. It is absolute. The above shows what I changed.
I just found the issue to this problem. It was not the component but a dependent component in
azure-test/components/azure_mqtt_handler/CMakeLists.txt
set(COMPONENT_SRCS "azure_mqtt_handler.c")
set(COMPONENT_ADD_INCLUDEDIRS "include")
set(COMPONENT_REQUIRES port mcommon)
register_component()
The dependency port was missing under COMPONENT_REQUIRES
Also keep in mind the file azure-test/CMakeLists.txt
include($ENV{MDF_PATH}/project.cmake)
set(EXTRA_COMPONENT_DIRS "${EXTRA_COMPONENT_DIRS} $ENV{ESP_AZURE}/port")
project(measure_mesh)
to have it include $ENV{ESP_AZURE}/port.
Thanks for your time!
Hello,
I am trying to use the SDK from within a component in the components directory without success. I am able to run the examples successfully but when moving the azure-dependent files to components directory it fails.
I am getting the following error
The error appears when having
#include "iothub_client.h"
in the fileazure_mqtt_handler.c
. The project structure that I have is the following.I have the correct IDF_PATH variable set and also downloaded the SDK into ESP_PATH/esp-azure. The following are the complete files, I've deleted everything else to try to find the issue.
azure-test/CMakeLists.txt
azure-test/main/main.c
azure-test/main/CMakeLists.txt
azure-test/components/azure_mqtt_handler/include/azure_mqtt_handler.h
azure-test/components/azure_mqtt_handler/azure_mqtt_handler.c
azure-test/components/azure_mqtt_handler/CMakeLists.txt
Thanks