Why does it say that the ‘File’ class is not declared?
I encluded <FS.h> and it didn’t work.
so I added build_flags = -I “FS.h path” but it also didn’t work.
src/main.cpp: In function 'void touch_calibrate()':
src/main.cpp:517:7: error: 'File' was not declared in this scope
#include "FS.h"
#include <LittleFS.h>
...
File f = LittleFS.open(CALIBRATION_FILE, "r");
if (f) {
if (f.readBytes((char *)calData, 14) == 14)
calDataOK = 1;
f.close();
}
[env]
platform = espressif32
framework = arduino, espidf
monitor_speed = 115200
[env:esp-wrover-kit]
board = esp-wrover-kit
lib_deps = bodmer/TFT_eSPI@^2.4.79
build_type = debug
build_flags =
-I "C:\Users\JJS\.platformio\packages\framework-arduinoespressif32\cores\esp32"
-I "C:\Users\JJS\.platformio\packages\framework-arduinoespressif32\variants\esp32"
-I "C:\Users\JJS\.platformio\packages\framework-arduinoespressif32\libraries\FS\src"
platform_packages =
platformio/tool-openocd-esp32@^2.1100.20220706
board_build.filesystem = littlefs
I converted LITTLEFS_test.ino to LITTLEFS_test.cpp for littleFS function test.
I created a function littleFS_test() in the main and built it, but a link error occurred.
What could be the problem?
Linking .pio\build\esp-wrover-kit\firmware.elf
c:/users/jjs/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp-wrover-kit\src\main.o:(.literal._ZL13littleFS_testv+0x8): undefined reference to `LittleFS'
c:/users/jjs/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp-wrover-kit\src\main.o:(.literal._ZL13littleFS_testv+0x44): undefined reference to `fs::LittleFSFS::begin(bool, char const*, unsigned char, char const*)'
c:/users/jjs/.platformio/packages/toolchain-xtensa-esp32/bin/../lib/gcc/xtensa-esp32-elf/8.4.0/../../../../xtensa-esp32-elf/bin/ld.exe: .pio\build\esp-wrover-kit\src\main.o: in function `littleFS_test()':
C:\Users\JJS\Documents\PlatformIO\Projects\221107-141244-espidf-arduino-wifiscan/src/main.cpp:579: undefined reference to `fs::LittleFSFS::begin(bool, char const*, unsigned char, char const*)'
- littleFS_test() in main.cpp
void littleFS_test(void)
{
if(!LittleFS.begin(FORMAT_LITTLEFS_IF_FAILED)){
Serial.println("LittleFS Mount Failed");
return;
}
...
Serial.println( "Test complete" );
}
This is almost always wrong. Let me double check how this can work.