Links2004 / arduinoWebSockets

arduinoWebSockets
GNU Lesser General Public License v2.1
1.89k stars 556 forks source link

No such file or directory "Wifi.h and WiFiClientSecure.h" with ESP32, Chain+ in PlatformIO #635

Open MohammedNoureldin opened 3 years ago

MohammedNoureldin commented 3 years ago

I am trying to add WebSocket to my ESP32 project, but unfortunately the compiler fails. Following is the error message I get:

...
Indexing .pio\build\esp32_dev\libc94\libArduinoJson.a Compiling .pio\build\esp32_dev\lib748\FS\FS.cpp.o Compiling .pio\build\esp32_dev\lib748\FS\vfs_api.cpp.o In file included from .pio/libdeps/esp32_dev/WebSockets/src/WebSocketsClient.h:28:0, from include/websocket/websocket_client.hpp:3, from src/websocket_client.cpp:1: .pio/libdeps/esp32_dev/WebSockets/src/WebSockets.h:190:30: fatal error: WiFiClientSecure.h: No such file or directory ...
.pio/libdeps/esp32_dev/WebSockets/src/WebSockets.h:189:18: fatal error: WiFi.h: No such file or directory
...

I am using PlatformIO IDE, below is my platformio.ini (the important part):

[env:esp32_dev]
framework = arduino
platform = espressif32
board = esp32dev
platform_packages = 
    ; Uses new tool chain with a non-released Arduino package to be able to compile with C++17 (C++17 may become the default in the future, therefore this may be soon not necessary).
    toolchain-xtensa@~5.100200.0
    framework-arduinoespressif32@https://github.com/espressif/arduino-esp32.git
build_unflags =
    -std=c++11
    -fno-exceptions ; Removes the default exceptions disabling flag.
build_flags =
    -std=c++17
    -D NO_GLOBAL_SERIAL1
lib_ldf_mode = chain+
lib_deps =
        ...
        ; Here I am using the not-released version, because I need a fix for ESP32.
    https://github.com/Links2004/arduinoWebSockets.git#ed685e551f9a1a992037f5fdc791a36c4c43abc0

Could anyone please help me to get it compiling? I am not sure what is wrong, because my project compiles as long as I do not add WebSocket library to it.

UPDATE:

Well, I have a new finding, changing lib_ldf_mode from chain+ to chain makes the project compiles. What is going wrong here? I need to use chain+. I believe this used to work in my ESP8266 projects.

Links2004 commented 3 years ago

this is normal and is based on how platform io is working.

you have to ways to get the "Wifi.h" auto detect via:

lib_ldf_mode = chain+

or manual via:

lib_deps = 
    WiFi
        WiFiClientSecure
MohammedNoureldin commented 3 years ago

@Links2004 Hi Markus, thanks for your reply. I am a bit confused. I am already using chain+, and this is exactly what triggers the problem, please find the minimal project I provided here:

https://github.com/platformio/platformio-core/issues/3876#issuecomment-799509343

Links2004 commented 3 years ago

ok, I where able to reproduce after some updates. but I dont understand why this happens for the ESP8266 lib_ldf_mode = chain+ is working fine, but with the ESP32 it failes.

MohammedNoureldin commented 3 years ago

@Links2004 , exactly, that was my observation as well. Do you have any idea what to do? I already reported this as a bug in PlatformIO repo in the link shown above.

MohammedNoureldin commented 3 years ago

Hi Markus, do you think it makes sense to build something temporary into the code or library.json as kind of workaround until PlatformIO guys fix the bug?

Please check their temporary workaround here:

https://github.com/platformio/platformio-core/issues/3876#issuecomment-800163580

Links2004 commented 3 years ago

the problem is that chain+ is required for ESP8266 and the NO_GLOBAL_INSTANCES define see https://github.com/Links2004/arduinoWebSockets/issues/624 forcing chain for the lib is no option since it will brake other code bases.

MohammedNoureldin commented 3 years ago

@Links2004 that is funny that the other issue was opened by meو too. I will think a bit about it then let you know if anything useful comes to my mind. Thank you Markus!

lemonkey commented 2 years ago

ugh

ggoksel commented 1 year ago

Thank you links2004..

yoroboticscolombia commented 10 months ago

HI, did you get it fixed?

steefst33f commented 10 months ago

for me actually completely removing:

lib_ldf_mode = deep+

in the platform.ini file made it compile without any errors. No idea why though...

bbuster2 commented 9 months ago

Any update on this? I am having the same errors with an ESP32. I need lib_ldf_mode = deep+ or lib_ldf_mode = chain+, otherwise it won't compile because BLEDevice.h is missing etc.

Even adding lib_deps= WiFi and WiFiClientSecure gives me the same errors