paclema / esp32_lwip_nat_example

4 stars 2 forks source link

undefined reference to `__locale_ctype_ptr' #3

Closed vell001 closed 2 years ago

vell001 commented 2 years ago

Linking .pio\build\mhetesp32minikit\firmware.elf c:/users/vell0/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\vell0.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32\lib\liblwip.a(utils.c.obj):(.literal.ppp_vslprintf+0x10): undefined reference to __locale_ctype_ptr' c:/users/vell0/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: C:\Users\vell0\.platformio\packages\framework-arduinoespressif32\tools\sdk\esp32\lib\liblwip.a(utils.c.obj): in functionppp_vslprintf': /home/pi/tmp/esp32-arduino-lib-builder/build/../esp-idf/components/lwip/lwip/src/netif/ppp/utils.c:181: undefined reference to __locale_ctype_ptr' c:/users/vell0/.platformio/packages/toolchain-xtensa-esp32@8.4.0+2021r2-patch3/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: /home/pi/tmp/esp32-arduino-lib-builder/build/../esp-idf/components/lwip/lwip/src/netif/ppp/utils.c:193: undefined reference to__locale_ctype_ptr' collect2.exe: error: ld returned 1 exit status *** [.pio\build\mhetesp32minikit\firmware.elf] Error 1 ========================= [FAILED] Took 11.90 seconds =========================

pablofr918 commented 2 years ago

Same problem here. Last week it was working but it started printing this error when compiling.

paclema commented 2 years ago

Please, use this repo as a guide as it is explained in the readme, not as a final working example. You can follow the steps to create your own arduino-esp32 framework with the LWIP capabilities or the ones that you need and they are not enbabled by the official arduino-esp32 framework.

This error might be caused because you are using a different toolchain-xtensa-esp32 version than the one that corresponds to the arduino-esp32 framework required when I compiled esp-idf at this point (toolchain-xtensa32@2.80400 defined in platformio.ini).

You have to recompile esp-idf enabling the LWIP properties that you need (like Enable NAT: https://github.com/paclema/esp32_lwip_nat_example/blob/main/docs/idf.py_menuconfig.png ) and afterward create your own arduino-esp32 framework to use it to compile your code.

In the example that you are using, the one that is in this repo, you can check that in platformio.ini, the framework that uses this example is:

platform_packages =
  framework-arduinoespressif32 @ https://github.com/paclema/arduino-esp32#lwip_enabled
  toolchain-xtensa32@2.80400  ; LWIP needs toolchain-xtensa32 >= v8.4.0

On the other hand, you have to check the toolchain-xtensa-esp32 version that you have to use for the framework-arduinoespressif32 you have just created, depending on the esp-idf version that you are using.

pablofr918 commented 2 years ago

The thing is that using your compiled framework and toolchain (toolchain-xtensa32@2.80400) is now giving the error. Is there anything that has changed?

paclema commented 2 years ago

So it looks from the error that @vell001 describes, that it is trying to link with the toolchain-xtensa-esp32@8.4.0+2021r2-patch3 but not with the toolchain-xtensa32@2.80400 So it might be there the issue?

https://registry.platformio.org/tools/platformio/toolchain-xtensa32/versions https://registry.platformio.org/tools/espressif/toolchain-xtensa-esp32s2/versions

I don't know if something changed, you can maybe check if platformio really gets the corresponding toolchain version that this example needs because I think that his 2021r2-patch3 might be causing the linking issue.

pablofr918 commented 2 years ago

Yes, it seems that PlatformIO is ignoring the toolchain version set in the platformio.ini. It uses the toolchain-xtensa-esp32@8.4.0+2021r2-patch3 even though we set the toolchain-xtensa32@2.80400.

paclema commented 2 years ago

Try with:

platform_packages =
  framework-arduinoespressif32 @ https://github.com/paclema/arduino-esp32#lwip_enabled
  platformio/toolchain-xtensa32@2.80400.210211  ; LWIP needs toolchain-xtensa32 v8.4.0

https://registry.platformio.org/tools/platformio/toolchain-xtensa32/installation?version=2.80400.210211

pablofr918 commented 2 years ago

I already tried but didn't work. It ends up using the other version.

Oopas commented 2 years ago

I already tried but didn't work. It ends up using the other version.

I encountered the same problem, which was solved after I tried to manually override the toolchain. 😉

paclema commented 2 years ago

Thank you @Oopas to verify the solution!