i-snore wrote on February 18, 2020:
I am trying to use the lwip Espressif component and various header files from it on a ESP32 board. I contacted AWS support and was redirected to this forum.
Our project layout:
/components
----/wifi
--------/include
------------dns.h < this is the file that tries to include the lwip files
--------/src
------------dns.c
--------CMakeLists.txt
/src
----main.c
When I go to include files from the component by writing,
#include "lwip/sys.h"
or
#include "lwip/dns.h"
the linker is unable to find the file and says that it doesn’t exist. (see below)
In file included from ../components/wifi/src/dns.c:5:0:
../components/wifi/include/dns.h:23:22: fatal error: lwip/sys.h: No such file or directory
compilation terminated.
However, I know that the lwip component is being built since the CMake logs show the following line:
Component names: soc log heap freertos vfs newlib esp_ringbuf driver tcpip_adapter esp_event partition_table app_update spi_flash mbedtls micro-ecc bootloader_support efuse xtensa-debug-module app_trace ethernet nvs_flash pthread smartconfig_ack wpa_supplicant espcoredump esp32 cxx i2c lwip ota wifi amazon-freertos-common secure_sockets esp_http_server freertos_plus_tcp bootloader nimble bt console esp_adc_cal esptool_py expat wear_levelling sdmmc fatfs freemodbus nghttp openssl spiffs ulp
This shows all of the components being compiled and on the next line it also shows the paths for each of those components - I didn’t copy & paste that for brevity.
Solutions I’ve tried:
- Hardcoding a relative path, e.g.
#include "../../amazon-freertos/lwip.."
and so forth,
However the problem with this was the #includes present within the lwip component itself weren’t able to succusefully include their own files since they were also written in the format of, “#include <lwip/header_file.h>”
- Copying and pasting the lwip component into my component directory
Here I ran into the compiler indicating that structs are being defined twice, which I have pasted below.
In file included from ../components/lwip/apps/dhcpserver/dhcpserver.c:23:0:
../amazon-freertos/vendors/espressif/boards/esp32/components/freertos_tcpip/tcpip_adapter/include/tcpip_adapter.h:52:16: error: redefinition of 'struct ip4_addr'
typedef struct ip4_addr {
^
In file included from ../components/lwip/lwip/src/include/lwip/ip_addr.h:43:0,
from ../components/lwip/lwip/src/include/lwip/inet.h:45,
from ../components/lwip/apps/dhcpserver/dhcpserver.c:17:
../components/lwip/lwip/src/include/lwip/ip4_addr.h:51:8: note: originally defined here
struct ip4_addr {
I’ve spent quite a bit of time on this and am not sure how to actually include the lwip component files in my components. I was hoping to get some help with this issue. Please let me know if any more information or context is required. Also, just as a final note, this is not the first time I am compiling my project. I have made other components and had them work fine, so I don’t think its a set up issue or an issue related to the CMake command I am running.
Thanks!
Compiler & CMake Info
I’m using CLion
+CMake Command+
/usr/local/bin/cmake -DCMAKE_BUILD_TYPE=Debug -DCMAKE_TOOLCHAIN_FILE=amazon-freertos/tools/cmake/toolchains/xtensa-esp32.cmake -GNinja /Users/vp/esp/Pebble_ESP32_Firmware
– The C compiler identification is GNU 5.2.0
– The CXX compiler identification is GNU 5.2.0
Edited by: i-snore on Feb 18, 2020 10:47 AM