Error when compiling with ESPAsyncWebServer library or so I think

Hello, good afternoon! Let’s see if someone can tell me where the error is…
I have a project on Arduino which works perfectly, but when it comes to transferring it to platformio I get an error, I have installed some of the libraries through the wizard and others with a zip file, since they do not appear in the list of libraries. When compiling the code I get the following error:

Processing esp32dev (platform: espressif32; framework: arduino; board: esp32dev)
-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.3.2) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.20009.0 (2.0.9)
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - tool-mkfatfs @ 2.0.1
 - tool-mklittlefs @ 1.203.210628 (2.3)
 - tool-mkspiffs @ 2.230.0 (2.30)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 39 compatible libraries
Scanning dependencies...
Dependency Graph
|-- WiFiManager @ 2.0.16-rc.2
|-- ESP Async WebServer @ 1.2.3
|-- ESPAsyncTCP @ 1.2.4
|-- WiFi @ 2.0.0
|-- LittleFS_esp32 @ 1.0.5
Building in release mode
Compiling .pio\build\esp32dev\src\principal.cpp.o
Building .pio\build\esp32dev\bootloader.bin
Generating partitions .pio\build\esp32dev\partitions.bin
esptool.py v4.5.1
Creating esp32 image...
Merged 1 ELF section
Successfully created esp32 image.
Compiling .pio\build\esp32dev\lib2ec\WiFi\WiFi.cpp.o
Compiling .pio\build\esp32dev\lib2ec\WiFi\WiFiAP.cpp.o
Compiling .pio\build\esp32dev\lib2ec\WiFi\WiFiClient.cpp.o
Compiling .pio\build\esp32dev\lib2ec\WiFi\WiFiGeneric.cpp.o
Compiling .pio\build\esp32dev\lib2ec\WiFi\WiFiMulti.cpp.o
Compiling .pio\build\esp32dev\lib2ec\WiFi\WiFiSTA.cpp.o
Compiling .pio\build\esp32dev\lib2ec\WiFi\WiFiScan.cpp.o
In file included from src/principal.cpp:11:
.pio/libdeps/esp32dev/WiFiManager/strings_en.h:7:2: warning: #warning "This file is deprecated" [-Wcpp]
 #warning "This file is deprecated"
  ^~~~~~~
src/principal.cpp: In function 'void setup()':
src/principal.cpp:99:39: error: 'handleFormText' was not declared in this scope
   server.on("/formulario", HTTP_POST, handleFormText);
                                       ^~~~~~~~~~~~~~
src/principal.cpp:100:40: error: 'handleFormText2' was not declared in this scope
   server.on("/formulario2", HTTP_POST, handleFormText2);
                                        ^~~~~~~~~~~~~~~
src/principal.cpp:101:40: error: 'handleFormText3' was not declared in this scope
   server.on("/formulario3", HTTP_POST, handleFormText3);
                                        ^~~~~~~~~~~~~~~
src/principal.cpp:102:40: error: 'handleFormText4' was not declared in this scope
   server.on("/formulario4", HTTP_POST, handleFormText4);
                                        ^~~~~~~~~~~~~~~
*** [.pio\build\esp32dev\src\principal.cpp.o] Error 1

I think it is a problem with the ESPAsyncWebServer library but I don’t know how to solve it. Thanks in advance! All the best!!

In a pure .cpp file, you need to declare the function prototype before you use it. This is in contrast to the .ino format in the Arduino. Double check that you are following the FAQ.

Hello, thank you for your answer, but I still have the same… I understand that you have to declare it before the Setup, but I don’t know how, the things I have always done have always been in Arduino and I wanted to manage platformio to have everything together (the website and program)…

The one that needs to be declared would be this, but I don’t know…

void handleFormText(AsyncWebServerRequest *request) {

xxxxxxx
xxxxxxxx
xxxxxxx
xxxxxx

}

AsyncWebServerRequest is a class, and *request I don’t know.

The procedure is always the same: You copy everything starting from the return value up before the function definition with the { begins, then add a semicolon.

So,

void handleFormText(AsyncWebServerRequest *request);

should be added in at the top of the src/principal.cpp file, but after all #include directives, so that the involved types are known.

1 Like

I tried that before answering but I got more errors, then I read in a forum thread that putting all the functions before setup could work, but nothing remains the same, in fact the errors increase…

Processing esp32dev (platform: espressif32; framework: arduino; board: esp32dev)
----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (6.3.2) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (cmsis-dap) External (cmsis-dap, esp-bridge, esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 @ 3.20009.0 (2.0.9)
 - tool-esptoolpy @ 1.40501.0 (4.5.1)
 - tool-mkfatfs @ 2.0.1
 - tool-mklittlefs @ 1.203.210628 (2.3)
 - tool-mkspiffs @ 2.230.0 (2.30)
 - toolchain-xtensa-esp32 @ 8.4.0+2021r2-patch5
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 39 compatible libraries
Scanning dependencies...
Dependency Graph
|-- WiFiManager @ 2.0.16-rc.2  
|-- ESP Async WebServer @ 1.2.3
|-- ESPAsyncTCP @ 1.2.4        
|-- WiFi @ 2.0.0
|-- LittleFS_esp32 @ 1.0.5     
Building in release mode
Compiling .pio\build\esp32dev\src\principal.cpp.o
In file included from src/principal.cpp:12:
.pio/libdeps/esp32dev/WiFiManager/strings_en.h:7:2: warning: #warning "This file is deprecated" [-Wcpp]
 #warning "This file is deprecated"
  ^~~~~~~
Compiling .pio\build\esp32dev\lib45e\ESPAsyncTCP\AsyncPrinter.cpp.o
Compiling .pio\build\esp32dev\lib45e\ESPAsyncTCP\ESPAsyncTCP.cpp.o
Compiling .pio\build\esp32dev\lib45e\ESPAsyncTCP\ESPAsyncTCPbuffer.cpp.o
Compiling .pio\build\esp32dev\lib45e\ESPAsyncTCP\SyncClient.cpp.o
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCPbuffer.cpp:27:10: fatal error: debug.h: No such file or directory

*************************************************************** 
* Looking for debug.h dependency? Check our library registry!   
*
* CLI  > platformio lib search "header:debug.h"
* Web  > https://registry.platformio.org/search?q=header:debug.h
*
***************************************************************

 #include <debug.h>
          ^~~~~~~~~
compilation terminated.
In file included from C:/Users/Jose Ramon/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/opt.h:51,
                 from C:/Users/Jose Ramon/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/init.h:40,
                 from .pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.h:31,
                 from .pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.h:26,
                 from .pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.cpp:22:
C:/Users/Jose Ramon/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/port/esp32/include/lwipopts.h:358: warning: "TCP_MSS" redefined
 #define TCP_MSS                         CONFIG_LWIP_TCP_MSS

In file included from .pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.h:25,
                 from .pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.h:26,
                 from .pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.cpp:22:
.pio/libdeps/esp32dev/ESPAsyncTCP/src/async_config.h:13: note: this is the location of the previous definition
 #define TCP_MSS (1460)

In file included from C:/Users/Jose Ramon/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/opt.h:51,
                 from C:/Users/Jose Ramon/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/init.h:40,
                 from .pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.h:31,
                 from .pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp:75:
C:/Users/Jose Ramon/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/port/esp32/include/lwipopts.h:358: warning: "TCP_MSS" redefined
 #define TCP_MSS                         CONFIG_LWIP_TCP_MSS

In file included from .pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.h:25,
                 from .pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp:75:
.pio/libdeps/esp32dev/ESPAsyncTCP/src/async_config.h:13: note: this is the location of the previous definition
 #define TCP_MSS (1460)

Compiling .pio\build\esp32dev\FrameworkArduino\esp32-hal-dac.c.o
Compiling .pio\build\esp32dev\FrameworkArduino\esp32-hal-gpio.c.o
In file included from C:/Users/Jose Ramon/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/opt.h:51,
                 from C:/Users/Jose Ramon/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/lwip/src/include/lwip/init.h:40,
                 from .pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.h:31,
                 from .pio/libdeps/esp32dev/ESPAsyncTCP/src/SyncClient.cpp:23:
C:/Users/Jose Ramon/.platformio/packages/framework-arduinoespressif32/tools/sdk/esp32/include/lwip/port/esp32/include/lwipopts.h:358: warning: "TCP_MSS" redefined
 #define TCP_MSS                         CONFIG_LWIP_TCP_MSS

In file included from .pio/libdeps/esp32dev/ESPAsyncTCP/src/SyncClient.h:32,
                 from .pio/libdeps/esp32dev/ESPAsyncTCP/src/SyncClient.cpp:22:
.pio/libdeps/esp32dev/ESPAsyncTCP/src/async_config.h:13: note: this is the location of the previous definition
 #define TCP_MSS (1460)

Compiling .pio\build\esp32dev\FrameworkArduino\esp32-hal-i2c-slave.c.o
*** [.pio\build\esp32dev\lib45e\ESPAsyncTCP\ESPAsyncTCPbuffer.cpp.o] Error 1
.pio/libdeps/esp32dev/ESPAsyncTCP/src/SyncClient.cpp:25:10: fatal error: interrupts.h: No such file or directory

********************************************************************
* Looking for interrupts.h dependency? Check our library registry!
*
* CLI  > platformio lib search "header:interrupts.h"
* Web  > https://registry.platformio.org/search?q=header:interrupts.h
*
********************************************************************

 #include <interrupts.h>
          ^~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\esp32dev\lib45e\ESPAsyncTCP\SyncClient.cpp.o] Error 1
.pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.cpp: In constructor 'AsyncPrinter::AsyncPrinter(AsyncClient*, size_t)':
.pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.cpp:48:5: error: 'panic' was not declared in this scope
     panic(); //What should we do?
     ^~~~~
.pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.cpp: In member function 'int AsyncPrinter::connect(IPAddress, uint16_t)':
.pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.cpp:71:5: error: 'panic' was not declared in this scope
     panic();
     ^~~~~
.pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.cpp: In member function 'int AsyncPrinter::connect(const char*, uint16_t)':
.pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.cpp:88:5: error: 'panic' was not declared in this scope
     panic();
     ^~~~~
.pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.cpp: In member function 'void AsyncPrinter::_onConnect(AsyncClient*)':
.pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.cpp:109:5: error: 'panic' was not declared in this scope
     panic();
     ^~~~~
.pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.cpp: In member function 'AsyncPrinter& AsyncPrinter::operator=(const AsyncPrinter&)':
.pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.cpp:130:5: error: 'panic' was not declared in this scope
     panic();
     ^~~~~
.pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.cpp: In member function 'size_t AsyncPrinter::_sendBuffer()':
.pio/libdeps/esp32dev/ESPAsyncTCP/src/AsyncPrinter.cpp:182:5: error: 'panic' was not declared in this scope
     panic(); // Connection should be aborted instead
     ^~~~~
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp: In member function 'bool AsyncClient::connect(IPAddress, uint16_t)':
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp:248:8: error: 'ip_addr_t' {aka 'struct ip_addr'} has no member named 'addr'; did you mean 'u_addr'?
   addr.addr = ip;
        ^~~~
        u_addr
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp: In member function 'bool AsyncClient::connect(const char*, uint16_t)':
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp:282:35: error: 'ip_addr_t' {aka 'struct ip_addr'} has no member named 'addr'; did you mean 'u_addr'?
     return connect(IPAddress(addr.addr), port);
                                   ^~~~
                                   u_addr
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp: In member function 'bool AsyncClient::operator==(const AsyncClient&)':
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp:331:66: error: 'ip_addr_t' {aka 'struct ip_addr'} has no member named 'addr'; did you mean 'u_addr'?
   return (_pcb != NULL && other._pcb != NULL && (_pcb->remote_ip.addr == other._pcb->remote_ip.addr) && (_pcb->remote_port == other._pcb->remote_port));
                                                                  ^~~~
                                                                  u_addr
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp:331:96: error: 'ip_addr_t' {aka 'struct ip_addr'} has no member named 'addr'; did you mean 'u_addr'?
   return (_pcb != NULL && other._pcb != NULL && (_pcb->remote_ip.addr == other._pcb->remote_ip.addr) && (_pcb->remote_port == other._pcb->remote_port));
                                                                                                ^~~~
                                                                                                u_addr
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp: In member function 'void AsyncClient::_dns_found(const ip_addr*)':
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp:707:31: error: 'const struct ip_addr' has no member named 'addr'; did you mean 'u_addr'?
     connect(IPAddress(ipaddr->addr), _connect_port);
                               ^~~~
                               u_addr
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp: In member function 'uint32_t AsyncClient::getRemoteAddress()':
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp:837:26: error: 'ip_addr_t' {aka 'struct ip_addr'} has no member named 'addr'; did you mean 'u_addr'?
   return _pcb->remote_ip.addr;
                          ^~~~
                          u_addr
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp: In member function 'uint32_t AsyncClient::getLocalAddress()':
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp:849:25: error: 'ip_addr_t' {aka 'struct ip_addr'} has no member named 'addr'; did you mean 'u_addr'?
   return _pcb->local_ip.addr;
                         ^~~~
                         u_addr
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp: In member function 'void AsyncServer::begin()':
.pio/libdeps/esp32dev/ESPAsyncTCP/src/ESPAsyncTCP.cpp:1122:14: error: 'ip_addr_t' {aka 'struct ip_addr'} has no member named 'addr'; did you mean 'u_addr'?
   local_addr.addr = (uint32_t) _addr;
              ^~~~
              u_addr
*** [.pio\build\esp32dev\lib45e\ESPAsyncTCP\AsyncPrinter.cpp.o] Error 1
*** [.pio\build\esp32dev\lib45e\ESPAsyncTCP\ESPAsyncTCP.cpp.o] Error 1

This is not right, that’s an ESP8266 library. You’re compling for ESP32.

The project page says to use AsycTCP. Double check your lib_deps expression.

1 Like

Wow… I’m in trouble with the libraries… that was because I didn’t look at the one I copied from the Arduino folder…
I think that now it compiles well, now I have to go for the flash memory that I want to use, 8MB instead of the 4MB that I had before… but that’s another story…
Thank you very much for helping and being patient! All the best!