You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
PlatformIO Core.
If you’ve found a bug, please provide an information below.
Configuration
Operating system:
Windows 10 Home Version 22H2(OS Build 19045.5371)
PlatformIO Version (platformio --version):
PlatformIO Core, version 6.1.16
Target Hardware:
esp32doit-devkit-v1
Description of problem
When developing a custom library, compilation will fail if a built-in library is included from a .cpp file within the custom library. Compilation will only pass if the custom library has a header file(.h) with the same name as the .cpp file. It must be in the same folder as the .cpp file and must be included from a .cpp file from the main program. The header file can be completely empty and it will still compile.
Steps to Reproduce
Create a custom library (source files below)
Include a built-in library (such as ArduinoOTA) from a .cpp file in the library
Include the library in another project
Make one of these breaking changes
Comment out the "#include <custom.h>" from the main.cpp file
Change the custom.h to any other name (update include in main.cpp to the new name to avoid unknown file errors)
Move custom.h to a different folder such as an include folder (update include in main.cpp to the new path to avoid unknown file errors if needed).
Try to compile the project
Actual Results
When you make any of the breaking changes you get this error message:
Compiling .pio\build\esp32doit-devkit-v1\lib22f\temp\custom.cpp.o
pathToProject/temp/src/custom.cpp:10:10: fatal error: ArduinoOTA.h: No such file or directory
********************************************************************
* Looking for ArduinoOTA.h dependency? Check our library registry!
*
* CLI > platformio lib search "header:ArduinoOTA.h"
* Web > https://registry.platformio.org/search?q=header:ArduinoOTA.h
*
********************************************************************
#include<ArduinoOTA.h>
^~~~~~~~~~~~~~
compilation terminated.
*** [.pio\build\esp32doit-devkit-v1\lib22f\temp\custom.cpp.o] Error 1
Expected Results
The compilation should have found the built-in library and complied properly like it does without the breaking changes.
// main.cpp
#include<Arduino.h>// empty header file with the same name as the .cpp file// commenting this out will cause the compilation error
#include<custom.h>// header that includes the function definitions
#include<linking.h>voidsetup()
{
Serial.begin(115200);
Serial.println("Setup complete");
}
voidloop()
{
sayHello();
}
Custom Library structure
src/custom.cpp
src/custom.h
src.linking.h
library.json
Custom Library Source files to reproduce issue:
custom.cpp:
// custom.cpp
#include<Arduino.h>// separate header file with different name to demonstate that the empty header file is required
#include"linking.h"// Fails when including built-in ota library if header file is changed or not included// commenting this include out will allow compliation without the empty header file
#include<ArduinoOTA.h>// also fails with the sd library// #include "FS.h"// #include "SD.h"// #include "SPI.h"voidsayHello()
{
Serial.println("Hello World");
delay(1000);
}
custom.h:
// custom.h// completely empty// Renaming or moving this file to another folder (such as an include folder) will cause compliation to fail
What kind of issue is this?
If you’ve found a bug, please provide an information below.
Configuration
Operating system:
Windows 10 Home Version 22H2(OS Build 19045.5371)
PlatformIO Version (
platformio --version
):PlatformIO Core, version 6.1.16
Target Hardware:
esp32doit-devkit-v1
Description of problem
When developing a custom library, compilation will fail if a built-in library is included from a .cpp file within the custom library. Compilation will only pass if the custom library has a header file(.h) with the same name as the .cpp file. It must be in the same folder as the .cpp file and must be included from a .cpp file from the main program. The header file can be completely empty and it will still compile.
Steps to Reproduce
Actual Results
When you make any of the breaking changes you get this error message:
Expected Results
The compilation should have found the built-in library and complied properly like it does without the breaking changes.
Source files for reproduction:
The content of
platformio.ini
:Main project source files to reproduce issue:
main.cpp
Custom Library structure
Custom Library Source files to reproduce issue:
custom.cpp:
custom.h:
linking.h:
library.json
Additional info
This only fails for built-in libraries. Other libraries included as dependencies of the custom library will be found and compile correctly.
The text was updated successfully, but these errors were encountered: