Hi,
I am having a project where multiple functionalities each have their own library. The library functions of course require each other. However at compiling I get the error lib/timer/timer.h:3:17: fatal error: led.h: No such file or directory
. Why can the compiler not see the file? I thought the include guard takes care of preventing a double include or loops, but the file should be still visible.
main.cpp:
#include <Arduino.h>
#include "button.h"
#include "led.h"
#include "web.h"
void setup(){}
void loop(){}
button.h:
#ifndef BUTTON_H
#define BUTTON_H
#include "led.h"
#include "web.h"
class button{};
#endif
led.h:
#ifndef LED_H
#define LED_H
#include "timer.h"
class led{};
#endif
timer.h:
#ifndef TIMER_H
#define TIMER_H
#include "led.h"
#include "web.h"
class timer{};
#endif
web.h:
#ifndef WEB_H
#define WEB_H
#include "timer.h"
class web{};
#endif
The corresponding .cpp files all just contain a #include "[library].h"
I am open for structuring my code differently, I just did not come up with a better idea. Thank you for your help.
Full build log:
Processing nodemcuv2 (platform: espressif8266; board: nodemcuv2; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif8266/nodemcuv2.html
PLATFORM: Espressif 8266 > NodeMCU 1.0 (ESP-12E Module)
HARDWARE: ESP8266 80MHz 80KB RAM (4MB Flash)
Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF MODES: FINDER(chain) COMPATIBILITY(soft)
Collected 55 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <ArduinoJson> 5.13.2
|-- <led>
| |-- <timer>
| | |-- <web>
|-- <button>
| |-- <led>
| | |-- <timer>
| | | |-- <web>
| |-- <web>
|-- <web>
Compiling .pioenvs/nodemcuv2/lib687/web/web.cpp.o
In file included from lib/web/web.h:3:0,
from lib/web/web.cpp:1:
lib/timer/timer.h:3:17: fatal error: led.h: No such file or directory
*************************************************************
* Looking for led.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:led.h"
* Web > https://platformio.org/lib/search?query=header:led.h
*
*************************************************************
#include "led.h"
^
compilation terminated.
Archiving .pioenvs/nodemcuv2/libc0c/libbutton.a
Archiving .pioenvs/nodemcuv2/libFrameworkArduinoVariant.a
Indexing .pioenvs/nodemcuv2/libc0c/libbutton.a
Indexing .pioenvs/nodemcuv2/libFrameworkArduinoVariant.a
Compiling .pioenvs/nodemcuv2/FrameworkArduino/Esp-version.cpp.o
*** [.pioenvs/nodemcuv2/lib687/web/web.cpp.o] Error 1
================================================================================================== [ERROR] Took 1.01 seconds