Import Arduino Project

Just for anyone else starting with Platformio:
Task: Import ESP32 existing arduino project.
Problem list:

  1. Can’t find <Arduino.h>, but it compiles
  2. Linker can’t find setup(), loop(), even when they exist in the source.

Internet search gave explanations as diverse as clang, library locations, compiling ‘test’ …

Four hours later, after multiple edits/reloads …

The problem was very simple. The arduino project was a .ino extension.
‘Import’ imported the .ino file.
Rename the .ino to .cpp (not .c) and all is well!

Who would know?

PIO can also use .ino files natively, but it is highly recommended to use correct .cpp files instead, as the FAQ (Redirecting...) says.

Closing as this question is already self-answered in the first post, but can’t mark first post as solution…

Not really a solution. ‘Import’ should at least ask about the .ino extensions and rename them to avoid hours of unnecessary googling and the attendant trial and error.
While the note in the documents can eventually be found with sufficient perseverance, surely import means import. If the best way to do it is to change the extension to .cpp then it should be the default, not something that requires hours of effort.
Surely an opensource project is there for inexperienced users as well as those who know.

1 Like

This is literally the first thing PIO tells you in the first second when you open a .ino file.

grafik

If you dismiss this warning, okay, it might take you hours to refind that. But it’s shown on every opening of the .ino file. When going to “Show instructions” it will take you to the FAQ via a shortlink.

grafik

I can’t really reproduce the problems you’re having regarding building, also. Starting from a Blink sketch

Pressing the “Import Arduino Project” button and pointing it to the folder

Generates the correct folder structure and platformio.ini, with the unmodified Blink.ino.

grafik

And building and uploading works perfectly. No code modifications needed.

So how do I reproduce the build problems that you’re having?

Maybe your warning means “change the extension” to you but I would suggest just saying so. It doesn’t say that to me.