fork/exec /Users/john/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++: bad CPU type in executable
Compilation error: fork/exec /Users/john/Library/Arduino15/packages/arduino/tools/avr-gcc/7.3.0-atmel3.6.1-arduino7/bin/avr-g++: bad CPU type in executable
The only thing I have found to try that applies to me is deleted:
Hi @boolrules. This error can be caused by not having Apple's Rosetta 2 software installed. Even though your Arduino IDE 2.x installation is a native Apple Silicon build, the tools used by Arduino IDE are still built for x86 host architecture. That is no problem as long as you have Rosetta 2 installed because it allows x86 applications to run perfectly on the Apple Silicon machines.
Normally when you start an x86 application macOS presents a dialog explaining that you need to install Rosetta 2:
However, I'm not sure whether that happens in this case where the x86 application is a tool running in a subprocess. This is a fairly new situation because we published the first native Apple Silicon build of Arduino IDE only a few weeks ago. I'll investigate the situation (unfortunately I already have Rosetta 2 installed on my M1 machine).
Please try manually installing Rosetta 2. I'll provide instructions:
Open your Applications folder in Finder.
Open the Utilities folder.
Double-click on "Terminal".
Type the following command in the Terminal window:
softwareupdate --install-rosetta
Accept the license agreement.
Wait for the installation to finish.
Now tray compiling your sketch again in Arduino IDE. Hopefully this time that "bad CPU type in executable" error will not occur and everything will work correctly.
Thank you for your very thorough reply.
See what happens when I assume stuff? Was hoping for a native build. I'll have to think about what I want to do here.
Thanks again. Much appreciated.
I'm not sure what the prospects will be of getting native Apple Silicon builds of the various helper tools and toolchain. It is unfortunately quite difficult to produce these builds. In the case of Arduino IDE, the payoff of better application performance makes the effort worthwhile, but I'm not sure there is such a significant benefit when it comes to some of these other tools, and the existing x86 builds are already working fine (even if maybe less efficiently) via Rosetta 2. Even if Arduino makes the native Apple Silicon builds of the tools we distribute directly, it is unlikely all the 3rd party platform maintainers will also do the same for their toolchains, so the problem will persist regardless.
At the very least, we plan to produce official documentation about the cause of this "bad CPU type in executable" error and the fix for it.
Please let us know if you have any other questions, concerns, or problems. I would also be interested to hear what you decide in the end. As I mentioned before, this is new territory for the project (and even for me personally since I bought my first M1 machine only a few weeks ago) so I am very interested in learning more and getting any feedback from the affected users.
Hi. M1Pro Ventura 13.2.1 user here. I've got the "avr-g++: bad CPU type in executable" error as well, and I can't shake it. Attempting the terminal-based Rosetta solution results in "Installing Rosetta 2 on this system is not supported. "
I did some research and found quite a few reports of macOS users (in general, nothing Arduin-specific) getting this error when running the softwareupdate --install-rosetta command. Unfortunately most of those reports did not have a resolution.
I think you might get this error from running the command on a Mac with an Intel processor, but you mentioned "M1Pro", which I assume means your Mac has an M1 processor?