I'm wondering if it's possible to use GNU (g++) to compile a arduino Sketch.

I wanna be able to unit test my code with catch2.

g++ -std=c++11 <filename> works well with catch2, but I obviously does not recognize Arduino's framework (Strings, Serial etc).

What I think is, maybe if I use Arduino's compiler [ which is compatible with -std=c++11 I would be able to do run the catch2 with the Arduino framework.

Does anyone knows where to find Arduino's compiler? or how to make GNU accept Arduino's framework?

  • Never heard of "catch2". But the "arduino" compiler is g++. avr-g++ to be precise. If you're using Linux you can install it as a system package if you like.
    – Majenko
    Jun 11, 2020 at 16:29
  • But if you're asking if you can compile Arduino code to run natively on a PC, no, not without using a core and board written specifically for the PC. You might look at Wiring-Pi as a starting point for that.
    – Majenko
    Jun 11, 2020 at 16:30
  • Some keywords that may help: "arduino-builder", "Sudar Arduino Makefile", "simavr". Jun 11, 2020 at 18:55


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.