khoih-prog / ESPAsync_WiFiManager

This is an ESP32 (including ESP32-S2 and ESP32-C3) / ESP8266 WiFi Connection Manager, using ESPAsyncWebServer, with fallback web configuration portal. Use this library for configuring ESP32, ESP8266 modules' WiFi, etc. Credentials at runtime. You can also specify static DNS servers, personalized HostName, fixed or random AP WiFi channel. With examples supporting ArduinoJson 6.0.0+ as well as 5.13.5- . Using AsyncDNSServer instead of DNSServer now.
MIT License
289 stars 72 forks source link

Linker errors after upgrading to 1.10.0 #81

Closed benpeart closed 2 years ago

benpeart commented 2 years ago

Describe the bug

After upgrading to version 1.10.0 I get the following link errors:

Linking .pio\build\node32s\firmware.elf .pio\build\node32s\src\main.cpp.o:(.literal._Z5setupv+0xe0): undefined reference to ESPAsync_WiFiManager::ESPAsync_WiFiManager(AsyncWebServer*, DNSServer*, char const*)' .pio\build\node32s\src\main.cpp.o:(.literal._Z5setupv+0xe4): undefined reference toESPAsync_WiFiManager::getStoredWiFiSSID()' .pio\build\node32s\src\main.cpp.o:(.literal._Z5setupv+0xe8): undefined reference to ESPAsync_WiFiManager::startConfigPortal(char const*, char const*)' .pio\build\node32s\src\main.cpp.o:(.literal._Z5setupv+0xec): undefined reference toESPAsync_WiFiManager::autoConnect(char const, char const)' .pio\build\node32s\src\main.cpp.o:(.literal._Z5setupv+0xf8): undefined reference to ESPAsync_WiFiManager::~ESPAsync_WiFiManager()' .pio\build\node32s\src\main.cpp.o: In functionsetup()': D:\src\kaleidoscope/.pio\libdeps\node32s\ArduinoJson\src/ArduinoJson/Deserialization/DeserializationError.hpp:20: undefined reference to ESPAsync_WiFiManager::ESPAsync_WiFiManager(AsyncWebServer*, DNSServer*, char const*)' .pio\build\node32s\src\main.cpp.o: In functionESPAsync_WiFiManager::WiFi_SSID()': D:\src\kaleidoscope/.pio\libdeps\node32s\ArduinoJson\src/ArduinoJson/Deserialization/DeserializationError.hpp:20: undefined reference to ESPAsync_WiFiManager::getStoredWiFiSSID()' .pio\build\node32s\src\main.cpp.o: In functionsetup()': D:\src\kaleidoscope/.pio\libdeps\node32s\ArduinoJson\src/ArduinoJson/Deserialization/DeserializationError.hpp:20: undefined reference to ESPAsync_WiFiManager::startConfigPortal(char const*, char const*)' D:\src\kaleidoscope/.pio\libdeps\node32s\ArduinoJson\src/ArduinoJson/Deserialization/DeserializationError.hpp:20: undefined reference toESPAsync_WiFiManager::autoConnect(char const, char const)' D:\src\kaleidoscope/.pio\libdeps\node32s\ArduinoJson\src/ArduinoJson/Deserialization/DeserializationError.hpp:20: undefined reference to ESPAsync_WiFiManager::~ESPAsync_WiFiManager()' D:\src\kaleidoscope/.pio\libdeps\node32s\ArduinoJson\src/ArduinoJson/Deserialization/DeserializationError.hpp:20: undefined reference toESPAsync_WiFiManager::~ESPAsync_WiFiManager()' collect2.exe: error: ld returned 1 exit status *** [.pio\build\node32s\firmware.elf] Error 1 ======================================================================================================== [FAILED] Took 36.03 seconds ========================================================================================================

No other changes were made.

Steps to Reproduce

I'm using Platform IO via Visual Studio code. Attempt to build a project using ESPAsync_WiFiManager.

Expected behavior

I expected my program to continue to link correctly.

Actual behavior

The changes in 1.10.0 to fix the linker errors apparently broke it for VS Code + Platform IO. After looking at the pull request, I added a line to include the -Impl.h file which 'fixed' the linker errors:

I was just including:

include

But after upgrading to 1.10.0 I had to add:

include "ESPAsync_WiFiManager-Impl.h"

to get it to link again.

Information

I updated everything to the latest versions:

pio update Updating platformio/contrib-piohome 3.4.0 @ ~3.4.0 [Up-to-date] Updating platformio/contrib-pysite 2.39.201019 @ ~2.39.0 [Incompatible 2.310.220102] Updating platformio/tool-scons 4.40300.1 @ ~4.40300.0 [Up-to-date]

Platform Manager
================
Platform espressif32

Updating platformio/espressif32 3.4.0 [Up-to-date] Updating platformio/toolchain-xtensa32 2.50200.97 @ ~2.50200.0 [Up-to-date] Updating platformio/framework-arduinoespressif32 3.10006.210326 @ ~3.10006.0 [Up-to-date] Updating platformio/tool-esptoolpy 1.30100.210531 @ ~1.30100.0 [Up-to-date] Updating platformio/tool-openocd-esp32 2.1000.20210721 @ ~2.1000.0 [Up-to-date] Updating platformio/tool-mkspiffs 2.230.0 @ ~2.230.0 [Up-to-date]

Library Manager

Library Storage: C:\Users\Ben.platformio\lib

PlatformIO 5.2.4 is currently the newest version available.

khoih-prog commented 2 years ago

After looking at the pull request, I added a line to include the -Impl.h file which 'fixed' the linker errors: I was just including:

include

But after upgrading to 1.10.0 I had to add:

include "ESPAsync_WiFiManager-Impl.h"

to get it to link again.

It's intentional. For example. check Async_ConfigOnDoubleReset.ino#L341-L342

#include <ESPAsync_WiFiManager.h>               //https://github.com/khoih-prog/ESPAsync_WiFiManager
#include <ESPAsync_WiFiManager-Impl.h>          //https://github.com/khoih-prog/ESPAsync_WiFiManager

Please read HOWTO Fix Multiple Definitions Linker Error

But be sure to use the following #include in just 1 .h, .cpp or .ino file, which must not be included in any other file, to avoid Multiple Definitions Linker Error