Error When Compiling GUIslice example (compiles OK in Arduino IDE)

I’m using VS Code on a Windows machine and trying to compile the GUIslice example the ex46_ard_togglebtn.ino example which compiled in fine in the Arduino IDE.

The error that happens is:

Compiling .pio\build\esp32dev\FrameworkArduino\Esp.cpp.o
.pio/libdeps/esp32dev/GUIslice/src/GUIslice_drv_tft_espi.cpp: In function 'bool gslc_DrvGetTxtSize(gslc_tsGui*, gslc_tsFont*, const char*, gslc_teTxtFlags, int16_t*, int16_t*, uint16_t*, uint16_t*)':
.pio/libdeps/esp32dev/GUIslice/src/GUIslice_drv_tft_espi.cpp:394:31: error: ISO C++ forbids declaration of 'type name' with no type [-fpermissive]
     m_disp.setFreeFont((const GFXfont *)pFont->pvFont);

When I follow the trail to GUIslice_drv_tft_espi.cpp:394:31 VS Code tells me that GFXfont is undefined but it is defined in Adafruit-GFX-Library/gfxfont.h at master · adafruit/Adafruit-GFX-Library (github.com) which is included in Adafruit-GFX-Library/Adafruit_GFX.h at master · adafruit/Adafruit-GFX-Library (github.com)

My platformio.ini file has the following

[platformio]
;lib_dir = .

[env]
;lib_ldf_mode = chain+ ;i also tried deep

[env:esp32dev]
platform = espressif32
;platform = https://github.com/platformio/platform-espressif32.git  ; will force to use the 2.0 board package
board = esp32dev
framework = arduino
lib_deps =
  SPI
  Wire
  adafruit/Adafruit BusIO
  adafruit/Adafruit GFX Library
  impulseadventure/GUIslice
  TFT_eSPI
  adafruit/Adafruit FT6206 Library  ; needed for GUIslice

build_flags =
  -DUSER_CONFIG_LOADED
  -DUSER_CONFIG_INC_FILE
  -DUSER_CONFIG_INC_FNAME=\"../configs/esp-tftespi-default-ft6206.h\"
  # Now TFT_eSPI Build Flags

So the Adafruit GFX Library is included but I can’t seem to find why it’s not found and as you can see I’ve tried a couple of different options in my platformio.ini file.

I could be wrong with the root cause of the compile error so I can provide more details if needed.

Unable to reproduce. Using your exact platformio.ini with this as src/main.cpp but with #include <Arduino.h> at the top produces

Processing esp32dev (platform: espressif32; board: esp32dev; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/espressif32/esp32dev.html
PLATFORM: Espressif 32 (3.5.0) > Espressif ESP32 Dev Module
HARDWARE: ESP32 240MHz, 320KB RAM, 4MB Flash
DEBUG: Current (esp-prog) External (esp-prog, iot-bus-jtag, jlink, minimodule, olimex-arm-usb-ocd, olimex-arm-usb-ocd-h, olimex-arm-usb-tiny-h, olimex-jtag-tiny, tumpa)
PACKAGES:
 - framework-arduinoespressif32 3.10006.210326 (1.0.6)
 - tool-esptoolpy 1.30100.210531 (3.1.0)
 - toolchain-xtensa32 2.50200.97 (5.2.0)
LDF: Library Dependency Finder -> https://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 36 compatible libraries
Scanning dependencies...
Dependency Graph
|-- <SPI> 1.0
|-- <Wire> 1.0.1
|-- <Adafruit BusIO> 1.11.2
|   |-- <Wire> 1.0.1
|   |-- <SPI> 1.0
|-- <Adafruit GFX Library> 1.10.13
|   |-- <SPI> 1.0
|   |-- <Adafruit BusIO> 1.11.2
|   |   |-- <Wire> 1.0.1
|   |   |-- <SPI> 1.0
|   |-- <Wire> 1.0.1
|-- <GUIslice> 0.17.0
|   |-- <Adafruit FT6206 Library> 1.0.6
|   |   |-- <Wire> 1.0.1
|   |-- <Adafruit STMPE610> 1.1.4
|   |   |-- <SPI> 1.0
|   |   |-- <Wire> 1.0.1
|   |-- <SPI> 1.0
|   |-- <Adafruit GFX Library> 1.10.13
|   |   |-- <SPI> 1.0
|   |   |-- <Adafruit BusIO> 1.11.2
|   |   |   |-- <Wire> 1.0.1
|   |   |   |-- <SPI> 1.0
|   |   |-- <Wire> 1.0.1
|   |-- <Adafruit ILI9341> 1.5.10
|   |   |-- <Adafruit GFX Library> 1.10.13
|   |   |   |-- <SPI> 1.0
|   |   |   |-- <Adafruit BusIO> 1.11.2
|   |   |   |   |-- <Wire> 1.0.1
|   |   |   |   |-- <SPI> 1.0
|   |   |   |-- <Wire> 1.0.1
|   |   |-- <SPI> 1.0
|   |-- <SD(esp32)> 1.0.5
|   |   |-- <FS> 1.0
|   |   |-- <SPI> 1.0
|   |-- <Adafruit TouchScreen> 1.1.3
|   |-- <Wire> 1.0.1
|   |-- <FS> 1.0
|   |-- <TFT_eSPI> 2.4.42
|   |   |-- <SPIFFS> 1.0
|   |   |   |-- <FS> 1.0
|   |   |-- <FS> 1.0
|   |   |-- <SPI> 1.0
|-- <TFT_eSPI> 2.4.42
|   |-- <SPIFFS> 1.0
|   |   |-- <FS> 1.0
|   |-- <FS> 1.0
|   |-- <SPI> 1.0
|-- <Adafruit FT6206 Library> 1.0.6
|   |-- <Wire> 1.0.1
Building in release mode
Compiling .pio\build\esp32dev\src\main.cpp.o
Retrieving maximum program size .pio\build\esp32dev\firmware.elf
Checking size .pio\build\esp32dev\firmware.elf
Advanced Memory Usage is available via "PlatformIO Home > Project Inspect"
RAM:   [          ]   4.9% (used 16024 bytes from 327680 bytes)
Flash: [==        ]  22.2% (used 291479 bytes from 1310720 bytes)
======================== [SUCCESS] Took 5.67 seconds ========================

I didn’t change the name to main.cpp so it still shows as the ino file in the src directory so maybe that’s it?

You still have the original includes, right?

#include "GUIslice.h"
#include "GUIslice_drv.h"

Thanks for testing for me!

OK drilling down on the problem. I too can compile as long as I don’t have the TFT_eSPI build flags. Once I add these to my platformio.ini I’m back to the error. I started with a fresh workspace and just created a new project and copied and pasted the example code into main.cpp.

  -DUSER_SETUP_LOADED=1
  -DBOARD_HAS_PSRAM=1
  -DILI9488_DRIVER=1                           ; Select ILI9488 driver
  -DTFT_WIDTH=320                              ; Set TFT size
  -DTFT_HEIGHT=480
  -DTFT_MISO=19                                ; Define SPI pins
  -DTFT_MOSI=23
  -DTFT_SCLK=18
  -DTFT_CS=5
  -DTFT_DC=14                                  ; Data/Comand pin
  -DTFT_RST=13                                 ; Reset pin
  -DTFT_BL=12                                  ; LED backlight control pin
  -DTFT_BACKLIGHT_ON=HIGH                      ; Level to turn on backlight
;  -DTOUCH_CS=21                                ; Not used but needed for compile
  -DLOAD_GLCD=1                                ; Load Fonts
  -DLOAD_FONT2=1          ; Font 2. Small 16 pixel high font, needs ~3534 bytes in FLASH, 96 characters
  -DLOAD_FONT4=1          ; Font 4. Medium 26 pixel high font, needs ~5848 bytes in FLASH, 96 characters
  -DLOAD_FONT6=1          ; Font 6. Large 48 pixel font, needs ~2666 bytes in FLASH, only characters 1234567890:-.apm
  -DLOAD_FONT7=1          ; Font 7. 7 segment 48 pixel font, needs ~2438 bytes in FLASH, only characters 1234567890:-.
  -DLOAD_FONT8=1          ; Font 8. Large 75 pixel font needs ~3256 bytes in FLASH, only characters 1234567890:-.
  -DSMOOTH_FONT=1
  -DSPI_FREQUENCY=27000000                     ; Set SPI frequency

OK, just stumbled across that if I comment out
; -DUSER_SETUP_LOADED=1
I can get it to compile. Since I still have the rest of my build flags I think I’m OK and things will work but I’m a bit confused on why I’m getting that compile error