如何解決 ESPAsyncWebServer 錯誤 - undefined reference to `mbedtls_md5_starts' (Solving ESPAsyncWebServer - undefined reference to `mbedtls_md5_starts issues )




最近在使用 ESPAsyncWebServer 時, 發生了一個編譯的錯誤:

c:/users/stone/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: d:\stone\Documents\build\libraries\ESPAsyncWebServer-master\WebAuthentication.cpp.o:(.literal._ZL6getMD5PhtPc+0x4): undefined reference to `mbedtls_md5_starts'


看來是 ESPAsyncWebServer 的問題, 於是我到 Git Hub 找到了 ESPAsyncWebServer https://github.com/me-no-dev/ESPAsyncWebServer 從新下載, 更新了 Library 還是沒有辦法, 錯誤依然存在, 無法解決. 

經過了3個小時反覆搜尋, 發現這是 ESPAsyncWebServer 的一個 issue, 目前還沒有被修正. 

不過, 在底下有高手提出了解決方法:
找到 WebAuthentication.cpp 然在大約 72 行左右, 

modify in the library directory your_directory/Arduino/libraries/ESPAsyncWebServer-master/src/WebAuthentication.cpp  @line 72 with this (the comment are the old line ......)

只要把原來的後3行紅色註解掉(//), 加上4個藍色新程式碼, 即可以修正!

#ifdef ESP32
mbedtls_md5_init(&_ctx);
mbedtls_md5_update_ret (&_ctx,data,len);
mbedtls_md5_finish_ret(&_ctx,data);
mbedtls_internal_md5_process( &_ctx ,data);

// mbedtls_md5_starts(&_ctx);
// mbedtls_md5_update(&_ctx, data, len);
// mbedtls_md5_finish(&_ctx, _buf);


-----------ENGLISH-------------

When I tried to compile ESPAsyncWebServer with AsyncElegantOTA, the following error occured:

c:/users/stone/appdata/local/arduino15/packages/esp32/tools/xtensa-esp32-elf-gcc/gcc8_4_0-esp-2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: d:\stone\Documents\build\libraries\ESPAsyncWebServer-master\WebAuthentication.cpp.o:(.literal._ZL6getMD5PhtPc+0x4): undefined reference to `mbedtls_md5_starts'


It looked like the ESPAsyncWebsrver issue, so I went to GitHub to re-download ESPAsyncWebServer (https://github.com/me-no-dev/ESPAsyncWebServer ) and then updated the library. However, this didn't solve the issue that the same error still stopping me from compile it for my ESP32.

After couple of hours, I realized that this was an error that didn't have a proper fixed yet. However, someone at Github provided a solution and it worked for me:

In line 72 of the WebAuthentication.cpp file:

modify in the library directory your_directory/Arduino/libraries/ESPAsyncWebServer-master/src/WebAuthentication.cpp  @line 72 with this (the comment are the old line ......)

Just comment these red in comment below and add the blue codes, then compile went fine without issues!

#ifdef ESP32
mbedtls_md5_init(&_ctx);
mbedtls_md5_update_ret (&_ctx,data,len);
mbedtls_md5_finish_ret(&_ctx,data);
mbedtls_internal_md5_process( &_ctx ,data);

// mbedtls_md5_starts(&_ctx);
// mbedtls_md5_update(&_ctx, data, len);
// mbedtls_md5_finish(&_ctx, _buf);

Comments

Popular posts from this blog

Arduino - DFPlayer Mini MP3 Module

Android control color RGB LED using HC-05 Bluetooth with Arduino (Part I)

Arduino #27 AsyncWifimanager ElegantOTA ESP32 (WiFi Password Mgnt. + WiFi Firmware Update)