CLion & PlatformIO vs VSCode & PlatformIO

I’ve Installed BOTH, but I can ONLY get the VSCode side to compile my code. Same Board (Mega 2560), Same Project even. I’m SURE this is something I have wrong on my CLion settings. I Finally got PlatformIO to Run on CLion with the install of MinGW Compiler, and Simple Scripts work fine. But when Build my “Work” scrip I get the following errors:

Building in debug mode

Linking .pio\build\megaatmega2560\firmware.elf
C:\Users\Pete\AppData\Local\Temp\ccc2DLXZ.s: Assembler messages:
C:\Users\Pete\AppData\Local\Temp\ccc2DLXZ.s:17099: Error: register r24, r26, r28 or r30 required
C:\Users\Pete\AppData\Local\Temp\ccc2DLXZ.s:17188: Error: register r24, r26, r28 or r30 required
lto-wrapper.exe: fatal error: avr-g++ returned 1 exit status
compilation terminated.
c:/users/pete/.platformio/packages/toolchain-atmelavr/bin/../lib/gcc/avr/7.3.0/../../../../avr/bin/ld.exe: error: lto-wrapper failed
collect2.exe: error: ld returned 1 exit status
*** [.pio\build\megaatmega2560\firmware.elf] Error 1
========================== [FAILED] Took 5.40 seconds ==========================

Process finished with exit code 1

Does ANYONE have an Idea of what is Wrong. The Same Code compiles using Arduino and PlarformIO and VSCode. Just NOT in CLion. I Should say I am on Win 10, 64Bit, 16 GB Memory.

I Get the SAME error on 32 Bit MinGW and 64 Bit MinGW, Microsoft Compiler Fails outright as does CygWin. I REALLY Want to use CLion, Not VSCode.

For CLion I remember I had to “pip Install platformio” into my Python 3.8. I recall some issues…So I just Uninstalled and REInstalled it.

These were the errors

Requirement already satisfied: ifaddr>=0.1.7 in d:\python\python38\lib\site-packages (from zeroconf==0.28.*->platformio) (0.1.7)
WARNING: Ignoring invalid distribution -qt5 (d:\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -yqt5 (d:\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -latformio (d:\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution - (d:\python\python38\lib\site-packages)
Installing collected packages: platformio
WARNING: Ignoring invalid distribution -qt5 (d:\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -yqt5 (d:\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -latformio (d:\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution - (d:\python\python38\lib\site-packages)
Successfully installed platformio-5.1.1
WARNING: Ignoring invalid distribution -qt5 (d:\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -yqt5 (d:\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -latformio (d:\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution - (d:\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -qt5 (d:\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -yqt5 (d:\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution -latformio (d:\python\python38\lib\site-packages)
WARNING: Ignoring invalid distribution - (d:\python\python38\lib\site-packages)

D:\Python\Python38\Scripts>

Seems to be Fix: Error: register r24, r26, r28 or r30 required - Andrey Mikhalchuk's Blog?

Does it in VSCode, also say

when building?

First, Thank You for your reply!

I Installed the latest Python 3.9.5, installed (pip install) platformio, and I have found a workaround. I’ve confirmed the works with ALL my code regardless of board (MEGA, UNO, ESP8266 ESP-01) all of them have have the same error in building, but the workaround solves the problem.

In CLion after Platform IO imports an Arduino Sketch, it produces two Build Options: Build Debug & Build Production

Sorry I intended to upload photo, but I am not allowed, so instead :

Tools → Platform IO-> Build Production
Tools → Platform IO-> Build

It also creates, CLion Build Configurations:

Can’t upload photo here either, once again text

Build-> Build Project
Build → Build All in ‘Uno’
Build → Build ‘Platform IO Upload’

My Work Around is to Choose Either the Tools → Platform IO → Build Production, or the CLion Menu Option of Build → Build 'Platform IO Upload’

And it works Perfectly, I just CANNOT choose the option of Platform IO → Build, or the CLion Menu: Build anything other than the Build Platform IO Upload.

SO, in short, I’m good. I can build code, utilize all of Resharper refactoring and code help and push to Boards. Goal achieved.

An ESP8266 boardh as the same error in building as you show here, regarding AVR registers? That should be impossible o_O.

First of all, are you sure that you’ve set up everything as per docs?

What’s the exact project that’s giving you the error?

You are Correct! I would have bet money I saw errors yesterday; BUT, testing just Now the UNO & ESP8266 BOTH can build Debug. It’s just My MEGA 2560 Sketch which has the problem.

But then ist must fail in the same way on VSCode + CLion for this project and debug configuration, right?

I Don’t follow your last comment.

VSCode builds Debug & Build Production BOTH. CLion, for the Mega Script, ONLY Build Production is Successful, the Debug Build throws the “Error: register r24, r26, r28 or r30 required”

But I honestly don’t care as Build Production is the MORE important build; as it is the one used to Upload sketch to Board…