Library dependecies broken aflter a merge

Hi all,
I merged the branch I was working on in main for a PIO project repo (but there was no conflict, so nothing is supposed to have changed in the files), and it seems like it broke my dependencies. I get errors coming from the library ESP32TimerInterrupt by Khoi Hoang. When I do a platformIO build, I get these errors:

.pio/libdeps/esp32thing_plus/ESP32TimerInterrupt/src/TimerInterrupt_Generic_Debug.h:50:30: error: ‘Serial’ was not declared in this scope

.pio/libdeps/esp32thing_plus/ESP32TimerInterrupt/src/ESP32_TimerInterrupt.h:166:56: error: ‘F’ was not declared in this scope

I tried deleting the contents of libdep folder and rebuilding, but no help.

Any idea what could have gone wrong that messes up the PIO build? May it be something in the .vscode folder? why doesnt it update itself automatically upon build if its the case?

Thanks a lot!

Im not familiar with ESP32 although I have a few, but…

Serial is from the Arduino framework. Are you using it?

Just because thete were no conflicts doesn’t mean things haven’t changed enough to bork your current code. :frowning_face:

Cheers,
Norm.

This was changed 6 days ago according to GitHub:

lib_compat_mode = strict
...
framework = arduino, espidf

Prior to that, the framework was arduino only and there was no lib_compat_mode.

The F() macro is part of the espressif32 framework for Arduino. It is defined at line 40 in WString.h as:

#define F(string_literal) (FPSTR(PSTR(string_literal)))

So, I suspect your project isn’t using the arduino framework but the library you are using needs it.

Cheers,
Norm.

Recently some libraries where merged because they were double in the library and one version was abandoned (ESP8266TimerInterrupt listing is outdated · Issue #12 · khoih-prog/ESP8266TimerInterrupt · GitHub).

This library might have been part of this.

Can you post the platformio.ini and minimal code that throws the error message?

I haven’t been able to reproduce the error yet with a minimal program. Using the library by itself seems to work fine, even when I call all of the functions I use in my other program…

Here is the .ini for my original program that doesnt compile:

; ###############################################################

; ESP32 Environment

; ###############################################################

; [env:esp-wrover-kit]

; board = esp-wrover-kit

[env:esp32thing_plus]

board = esp32thing_plus

; ###############################################################

; ESP32-PROG Environment (remove if uploading directly to ESP32)

; ###############################################################

; unmask this block when debugging, otherwise comment out

; monitor_speed = 115200    

; debug_tool = esp-prog

; debug_speed = 12000

; debug_init_break = tbreak setup

; upload_protocol = esp-prog

; upload_port = COM22

; unused parameters

; board_build.mcu = esp32

; board_build.f_cpu = 240000000L

; ###############################################################

platform = espressif32

framework = arduino

build_flags =

    -DTFT_MOSI=18

    -DTFT_SCLK=5

    -DUSER_SETUP_LOADED=1

    -DST7789_DRIVER=1

    -DTFT_WIDTH=240

    -DTFT_HEIGHT=240

    -DST7789_GREENTAB2=1

    -DTFT_RST=32

    -DTFT_CS=-1

    -DTFT_DC=A5

    -DLOAD_GLCD=1

    -DLOAD_FONT2=1

    -DLOAD_FONT4=1

    -DLOAD_FONT6=1

    -DLOAD_FONT7=1

    -DLOAD_FONT8=1

    -DLOAD_FONT8N=1

    -DLOAD_GFXFF=1

    -DSMOOTH_FONT=1

    -DSPI_FREQUENCY=27000000

   

; ###############################################################

; Project Libraries

; ###############################################################

lib_extra_dirs =  C:\Users\jcbsk\Documents\Libraries, C:\Users\jcbsk\Documents\GaitSpeedSensor\GaitSensor_Libraries

lib_deps =

    Wire

    bodmer/TFT_eSPI@^2.3.66         ; if trouble with building (SPI no such file, ...), include it in ur project

    khoih-prog/ESP32TimerInterrupt@^1.4.0

    pololu/VL53L1X@^1.3.0

I tried copying this in an empty project, and I had a different problem: the TFT_eSPI library would not compile, even when no header was included in my empty program. The problem was a FS.h file that could not be found…

Compiling .pio\build\esp32thing_plus\lib885\VL53L1X\VL53L1X.cpp.o
Archiving .pio\build\esp32thing_plus\libFrameworkArduinoVariant.a
Indexing .pio\build\esp32thing_plus\libFrameworkArduinoVariant.a
In file included from .pio\libdeps\esp32thing_plus\TFT_eSPI\TFT_eSPI.h:65:0,
                 from .pio\libdeps\esp32thing_plus\TFT_eSPI\TFT_eSPI.cpp:17:
.pio\libdeps\esp32thing_plus\TFT_eSPI\Processors/TFT_eSPI_ESP32.h:84:18: fatal error: FS.h: No such file or directory

That puzzles me quite a lot, either both libraries are problematic, or there is something else that prevents PIO from properly including dependencies when building.

I do not think the merge was the problem in that case :stuck_out_tongue:

The thing is I always had arduino as the framework in my .ini… I tried putting it as the first line in my .ini env but it did not remove the issue… I tried replacing the board too. I am stuck!

if it doesn’t find a sub-library, try adding

lib_ldf_mode = chain+

in the platformio.ini (Redirecting...).

This did not change anything, but removing <Arduino.h> from my empty project gave the error in my program. I decided to try putting <Arduino.h> in all of my files in my original program and it now compiles.

My problem is solved, but I have a few questions for my understanding:

  1. all of my files had dependencies containing <Arduino.h>. Why is that it would not compile, does it mean sometimes the make file compiles files before adding all of its dependencies (should not be the case because includes are supposed to paste the content of files in a recursive manner)?
  2. Is it good practice to put includes in a redundant way like I just did, given that files all require Arduino.h, but their tree already includes Arduino.h

thanks again!

If you are used to the Arduino IDE, you never need to put include statements, unless the IDE does it when you add a library. However, this only works for *.ino files. PlatformIO can compile those too but treats them in a similar manner to *.cpp fles in that the developer, not the IDE, has to remember to include all the required header files. The Arduino IDE does it in the background, hidden from view.

Including Arduino.h where it is required is not a problem. Although the tree may contain it, it must still be included in all “compilation units” where it is needed. If you are not sure which files need it, look for Arduino specific “stuff” like function calls in the source file. If there are any, you need it.

HTH

Cheers,
Norm.

I meant my dependency tree was already functional, i.e.

|-- <Arduino>
|   |-- <customHeader>
|   |   |-- <main>

so Arduino was included in the custom header, therefore it should have been in main… Yet my dependecy problems were solved by doing something like this:

|-- <Arduino>
|   |-- <customHeader>
|   |-- <Arduino>
|   |   |-- <main>

so I added Arduino.h directly in main even though some of its includes already had Arduino.h … I want to understand why this solved the issue, it seems like the compiler did not behave the way I expected in this situation.

Sorry, lack of sleep – my puppy was ill during the wee small hours, and I’ve been awake since about 2 AM!

If I follow you, your main source file #includes "customheader.h" and that file, #includes "Arduino.h". That should have brought Arduino.h in quite happily. Unless it had already been included in the same source file, some other way.

Your fix, again if I follow correctly, was to add Arduino.h to main as well as having it included by the customheader.h file. In this case, I would expect the second inclusion to ignore it as it has “include guards” to stop it being included more than once in any single compilation unit.

I don’t quite understand how you were not getting the Arduino.h properly included in the original manner in that case. It might be helpful to see the code? If there’s nothing confidential in it. Can you drop it somewhere handy like dropbox or similar, if it’s large?

Cheers,
Norm.

1 Like