While running the software on the PlatformIO IDE software I get the following error
First run was successful
But I tried a second time and the following error appeared
collect2.exe: error: ld returned 1 exit status
* [.pio\build\uno\firmware.elf] Error 1
========== [FAILED] Took 1.72 seconds ==========
That just seems to be the last line of the error log.
Can you show the complete log, please?
I tested on another computer with VSC+PlatformIO IDE installed
Same error here too
Works fine after installation and after I move to another project
The software gives the error message when running
!+++++++++++++
- Executing task in folder slomolm: C:\Users\IRISZ.platformio\penv\Scripts\platformio.exe run
Processing uno (platform: atmelavr; board: uno; framework: arduino)
Verbose mode can be enabled via -v, --verbose
option
CONFIGURATION: Redirecting...
PLATFORM: Atmel AVR (5.0.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES:
- framework-arduino-avr @ 5.2.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 6 compatible libraries
Scanning dependencies…
Dependency Graph
|-- LiquidCrystal_I2C @ 1.1.4
|-- Wire @ 1.0
Building in release mode
Linking .pio\build\uno\firmware.elf
C:\Users\IRISZ\AppData\Local\Temp\ccxbiuuv.ltrans0.ltrans.o: In function main': <artificial>:(.text.startup+0xc8): undefined reference to
setup’
:(.text.startup+0xd0): undefined reference to `loop’
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\uno\firmware.elf] Error 1
============================ [FAILED] Took 1.80 seconds ============================
- The terminal process “C:\Users\IRISZ.platformio\penv\Scripts\platformio.exe ‘run’” terminated with exit code: 1.
- Terminal will be reused by tasks, press any key to close it.
The error message says: There is no setup
and no loop
function.
I didn’t understand the answer?
You have an arduino project.
Arduino projects need a setup
and a loop
function. These functions are missing in your code.
https://docs.arduino.cc/built-in-examples/basics/BareMinimum/
#include <Wire.h>
#include <LiquidCrystal_I2C.h>
// Set the LCD address to 0x27 for a 16 chars and 2 line display
LiquidCrystal_I2C lcd(0x27, 16, 2);
void setup() {
// Initialize the LCD
lcd.init();
// Turn on the backlight
lcd.backlight();
}
void loop() {
// Print a message to the LCD
lcd.setCursor(0, 0); // Set the cursor to column 0, row 0
lcd.print(“Hello World!”);
}
- Executing task in folder helloworld: C:\Users\irisz.platformio\penv\Scripts\platformio.exe run
Processing uno (platform: atmelavr;
board: uno; framework: arduino)
------------------Verbose mode can be enabled via -v, --verbose
optionCONFIGURATION: https://docs.platformio.org/page/boards/atmelavr/uno.htmlPLATFORM: Atmel AVR (5.0.0) > Arduino Uno
HARDWARE: ATMEGA328P 16MHz, 2KB RAM, 31.50KB Flash
DEBUG: Current (avr-stub) External (avr-stub, simavr)
PACKAGES:
- framework-arduino-avr @ 5.2.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 6 compatible libraries
Scanning dependencies…
Dependency Graph
|-- LiquidCrystal_I2C @ 1.1.4
|-- Wire @ 1.0
Building in release mode
Linking .pio\build\uno\firmware.elf
C:\Users\irisz\AppData\Local\Temp\ccKpLbTq.ltrans0.ltrans.o: In function main': <artificial>:(.text.startup+0xc8): undefined reference to
setup’
:(.text.startup+0xd0): undefined reference to `loop’
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\uno\firmware.elf] Error 1
[FAILED] Took 1.97 seconds
- The terminal process “C:\Users\irisz.platformio\penv\Scripts\platformio.exe ‘run’” terminated with exit code: 1.
- Terminal will be reused by tasks, press any key to close it.
This is the code and this and the error message
If I run the code in Arduino IDE
Working right
PlatformIO IDE software has a problem
Please use pre-formatted text for code and logs. Otherwise this is very difficult to read.
What is your folder and file structure? In which file is your source code?
Create a new PlatformIO project. Then copy your code into src/main.cpp. And add the libraries to the platformio.ini.
Maybe there is some garbage from your last built.
Clean the project (PlatformIO Icon → Project Task → Clean).
Please use pre-formatted text when posting code or logs. See the link from above.
I opened a new project and copied the code there
Same error message?
Make sure that the correct project is selected. Better: just have a single project open in vs code workspace.
I started a new project
With default code I got when opening the project works fine
The problem when I copy code from Arduino IDE
with a *.ino extension
I copy and paste
to the software
PlatformIO – SRC – main.cpp
So I get the error line
I also tried copying the code to
PlatformIO – platformio.ini
And I get an error?
How to pass code from Arduino IDE software
to PlatformIO software?
?
I added the Arduino.h
problem solved
Thank you !!
There is a new problem
Only the last project works properly
If I move to previous projects does it not work?
The project works until I add a new project and then the previous project does not work?
Make sure you have selected the correct project and environment in the project environment switcher