Library dependencies and includes in Visual Studio Code

I’m trying to get started using Visual Studio Code with my Arduino via

I’ve imported my first project, a installed the only library I need, which is StateMachine.h. I did this using the home tab and then going to Libraries in the main menu.

There seems to be an includes error and a dependency error. StateMachine comes with state.h included, but Visual Studio Code shows an include error even though the state.h file is present.

StateMachine also requires LinkedList.h which appears to be another library, but that has not automatically been installed. LinkedList has it’s own dependencies, so I’d prefer to find a way to resolving these automatically rather than following a long chain.

I’ve spent a few evenings looking into this but I’m weary of messing something up and making things worse. Any help is appreciated.

Thank you

Please show your current platformio.ini and the current compile error.

Also note that sometimes the Intellisense shows “errors” which will resolve themselves after the Intellisense index is updated (Ctrl+Shift+P → Rebuild Intellisense Index)

Hi. I’ve pasted the platformio.ini file below.

platform = atmelavr
board = megaatmega2560
framework = arduino
lib_deps =

I’ve had some progress. I went and installed the LinkedList library, same way, via the Visual Studio Platformio home tab. This seems to have resolved the include error and the library dependency.

I do now get a new unknown error when I try to build my sketch:

  • Executing task in folder TomCat Wifi Statemachine: C:\Users\Philip.platformio\penv\Scripts\platformio.exe run

Processing megaatmega2560 (platform: atmelavr; board: megaatmega2560; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------------------------------------------Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Atmel AVR (4.0.0) > Arduino Mega or Mega 2560 ATmega2560 (Mega 2560)
HARDWARE: ATMEGA2560 16MHz, 8KB RAM, 248KB Flash
DEBUG: Current (avr-stub) On-board (avr-stub, simavr)

  • framework-arduino-avr @ 5.1.0
  • toolchain-atmelavr @ 1.70300.191015 (7.3.0)
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 8 compatible libraries
    Scanning dependencies…
    Dependency Graph
    |-- StateMachine @ 1.0.11
    | |-- LinkedList @ 0.0.0-alpha+sha.dac3874d28
    |-- LinkedList @ 0.0.0-alpha+sha.dac3874d28
    Building in release mode
    Compiling .pio\build\megaatmega2560\src\main.cpp.o
    Archiving .pio\build\megaatmega2560\libFrameworkArduinoVariant.a
    Compiling .pio\build\megaatmega2560\FrameworkArduino\CDC.cpp.o
    Compiling .pio\build\megaatmega2560\FrameworkArduino\HardwareSerial.cpp.o
    Compiling .pio\build\megaatmega2560\FrameworkArduino\HardwareSerial0.cpp.o
    Compiling .pio\build\megaatmega2560\FrameworkArduino\HardwareSerial1.cpp.o
    Compiling .pio\build\megaatmega2560\FrameworkArduino\HardwareSerial2.cpp.o
    Compiling .pio\build\megaatmega2560\FrameworkArduino\HardwareSerial3.cpp.o
    Compiling .pio\build\megaatmega2560\FrameworkArduino\IPAddress.cpp.o
    Compiling .pio\build\megaatmega2560\FrameworkArduino\PluggableUSB.cpp.o
    Compiling .pio\build\megaatmega2560\FrameworkArduino\Print.cpp.o
    Compiling .pio\build\megaatmega2560\FrameworkArduino\Stream.cpp.o
    Compiling .pio\build\megaatmega2560\FrameworkArduino\Tone.cpp.o
    Compiling .pio\build\megaatmega2560\FrameworkArduino\USBCore.cpp.o
    *** [.pio\build\megaatmega2560\libFrameworkArduinoVariant.a] Error 3221225477
    *** [.pio\build\megaatmega2560\src\main.cpp.o] Error 3221225477
    ====================================================================== [FAILED] Took 2.98 seconds ======================================================================
  • The terminal process “C:\Users\Philip.platformio\penv\Scripts\platformio.exe ‘run’” terminated with exit code: 1.
  • Terminal will be reused by tasks, press any key to close it.

That’s the windows error code for STATUS_ACCESS_VIOLATION, i.e. the program crashed. Do you have antivirus beyond Windows Defender installed that could prevent some programs from running?