Unable to build any project - Help me

Hi everybody!

I am tring to fix a problema with my installation of PlatformIO over VS Code for two days. I coded, builded and uploaded Arduino Mega project for about one year. I don’t know why it not works anymore since Friday.
Trying to fix the problema, I have reinstalled it for about ten times, change versions… but i ever get the same error.
The envoriment is Windows 10, VS Code 1.44.2, PlatformIO 1.10.0.

Here a very basic code (and any other one) that not works (main.cpp file on /src folder):

#include <Arduino.h>

int a;

void setup() {
  a = 5;
}

void loop() {
  // put your main code here, to run repeatedly:
}

The platformio.ini file is:

[env:megaatmega2560]
platform = atmelavr
board = megaatmega2560
framework = arduino

When I build the project, this error happens:

PS C:\Users\Dev\Documents\PlatformIO\Projects\Test> C:\Users\Dev\.platformio\penv\Scripts\platformio.exe run -v
Processing megaatmega2560 (platform: atmelavr; board: megaatmega2560; framework: arduino)
------------------------------------------------------------------------------------------------------------------------------------

CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/megaatmega2560.html
PLATFORM: Atmel AVR 2.0.0 > Arduino Mega or Mega 2560 ATmega2560 (Mega 2560)
HARDWARE: ATMEGA2560 16MHz, 8KB RAM, 248KB Flash
PACKAGES:
 - framework-arduino-avr 5.0.0
 - toolchain-atmelavr 1.50400.190710 (5.4.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
avr-g++ -o .pio\build\megaatmega2560\firmware.elf -Os -mmcu=atmega2560 -Wl,--gc-sections -flto -fuse-linker-plugin .pio\build\megaatmega2560\src\main.cpp.o -L.pio\build\megaatmega2560 -Wl,--start-group .pio\build\megaatmega2560\libFrameworkArduinoVariant.a .pio\build\megaatmega2560\libFrameworkArduino.a -lm -Wl,--end-group
C:\Users\Dev\AppData\Local\Temp\ccIKBZ2U.ltrans0.ltrans.o: In function `main':
<artificial>:(.text.startup+0x0): undefined reference to `init'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\megaatmega2560\firmware.elf] Error 1

o_O sounds like startup code cannot find the framework files? I suggest that you open a Windows explorer, navigate to C:\Users\Dev\.platformio\packages and delete every folder found inside this repository. PlatformIO will re-download everything upon the next compile, in a hopefully clean version.

Hi @maxgerhardt, thanks for your help!

I just deleted every folders inside packages. Alfter, I open Visual Code, it reloads a lot of things. But, after it, I got this two messages before build:

#include errors detected. Please update your includePath. Squiggles are disabled for this translation unit (C:\Users\Dev\Documents\PlatformIO\Projects\Test\src\main.cpp).
cannot open source file “Arduino.h”

So, i thinked it is was caused for the deleted packages.
I tryed again to build and got the other problem:

C:\Users\Dev.platformio\penv\Scripts\platformio.exe run <

Processing megaatmega2560 (platform: atmelavr; board: megaatmega2560; framework: arduino)

PackageManager: Installing toolchain-atmelavr @ ~1.50400.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
toolchain-atmelavr @ 1.50400.190710 has been successfully installed!
PackageManager: Installing framework-arduino-avr @ ~5.0.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
framework-arduino-avr @ 5.0.0 has been successfully installed!
CorePackageManager: Installing tool-scons @ ~3.30102.0
Downloading [####################################] 100%
Unpacking [####################################] 100%
tool-scons @ 3.30102.0 has been successfully installed!
Verbose mode can be enabled via -v, --verbose option
CONFIGURATION: Redirecting...
PLATFORM: Atmel AVR 2.0.0 > Arduino Mega or Mega 2560 ATmega2560 (Mega 2560)
HARDWARE: ATMEGA2560 16MHz, 8KB RAM, 248KB Flash
PACKAGES:

  • framework-arduino-avr 5.0.0
  • toolchain-atmelavr 1.50400.190710 (5.4.0)
    LDF: Library Dependency Finder → Library Dependency Finder (LDF) — PlatformIO latest documentation
    LDF Modes: Finder ~ chain, Compatibility ~ soft
    Found 6 compatible libraries
    Scanning dependencies…
    No dependencies
    Building in release mode
    Compiling .pio\build\megaatmega2560\FrameworkArduino\wiring.c.o
    *** [.pio\build\megaatmega2560\FrameworkArduino\wiring.c.o] Error -1
    =================================================== [FAILED] Took 80.15 seconds ===================================================
    The terminal process terminated with exit code: 1

And the "#include <Arduino.h> is red underlined and the two problems still is showed.

Yes, the Intellisense errors are temporary for until the files are redownloaded.

Is there any antivirus program running on your PC, which you could temporarily disable? I don’t see why that should fail now.

Also can you give the result of a “Verbose Build” within VSCode?

1 Like

@maxgerhardt, the problem was caused by the antivirus.
I don’t believe it was so simple problem! More than twety hours lost.
But it is a kind of surprises caused by multiple users machine. My daugther has installed a new antivirus.
Thanks a lot, dude!!!

1 Like

ive same problem like that, but when i disabling my antivirus,instead i deleted one of my antifirus. and i disabled kaspersky antivirus. but still failed to build.

> Executing task: C:\Users\ridho\.platformio\penv\Scripts\platformio.exe run <

Processing uno (platform: atmelavr; board: uno; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR 2.1.0 > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES:
 - framework-arduino-avr 5.0.0
 - toolchain-atmelavr 1.50400.190710 (5.4.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Linking .pio\build\uno\firmware.elf
C:\Users\ridho\AppData\Local\Temp\ccavXMa6.ltrans0.ltrans.o: In function `main':
<artificial>:(.text.startup+0x0): undefined reference to `init'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\uno\firmware.elf] Error 1
==================================================== [FAILED] Took 2.59 seconds ====================================================
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

> Executing task: C:\Users\ridho\.platformio\penv\Scripts\platformio.exe run <

Processing uno (platform: atmelavr; board: uno; framework: arduino)
-------------------------------------------------------------------------------------------------------------------------------------
Verbose mode can be enabled via `-v, --verbose` option
CONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.html
PLATFORM: Atmel AVR 2.1.0 > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (simavr) On-board (simavr)
PACKAGES:
 - framework-arduino-avr 5.0.0
 - toolchain-atmelavr 1.50400.190710 (5.4.0)
LDF: Library Dependency Finder -> http://bit.ly/configure-pio-ldf
LDF Modes: Finder ~ chain, Compatibility ~ soft
Found 6 compatible libraries
Scanning dependencies...
No dependencies
Building in release mode
Linking .pio\build\uno\firmware.elf
C:\Users\ridho\AppData\Local\Temp\cceafxca.ltrans0.ltrans.o: In function `main':
<artificial>:(.text.startup+0x0): undefined reference to `init'
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\uno\firmware.elf] Error 1
==================================================== [FAILED] Took 2.14 seconds ====================================================
The terminal process terminated with exit code: 1

Terminal will be reused by tasks, press any key to close it.

or what should i do?

Still seems like broken framework files to me. Try to delete C:\Users\<User>\.platformio\packages and retry.