0

On a Pi, to execute a C++ code, you'll need a Makefile.

Is there an equivalent with the Arduino? Where I have some valid C++ files to upload without the IDE's help, but instead with an executable?

Dat Ha
  • 2,883
  • 6
  • 21
  • 44
  • See also http://arduino.stackexchange.com/questions/32998/how-to-convert-arduino-example-sketch-to-a-complete-c-project – gilhad Jan 24 '17 at 20:35
  • On a Pi you absolutely do not need a Makefile to **execute** C++ code. Regarding **building** an executable from C++ code on Pi, you **may** want to use a Makefile to help you do it, but having a Makefile is in no way mandatory. – jfpoilpret Jan 28 '17 at 13:26
  • You can find several Makefile solutions for Arduino on Internet. Some of them are listed in this question: http://arduino.stackexchange.com/questions/348/how-to-organize-my-arduino-projects-structure-for-easy-source-control Now since I am using NetBeans IDE for my Arduino projects (check out https://github.com/jfpoilpret/fast-arduino-lib/blob/master/ArduinoDevSetup.docx for a description of my setup), it automatically creates Makefiles for me. – jfpoilpret Jan 28 '17 at 13:29

2 Answers2

2

Whether you compile manually with a Makefile (or Arduino-Builder) or in the IDE, the end result is a HEX file. This is a text file describing the data to load into the flash memory.

You then use avrdude to install it into the Arduino - either from the IDE or by running it manually (or specifying it in your Makefile, etc).

A Makefile doesn't produce an executable. A Makefile is merely a recipe - a set of instructions - telling the make program which programs to run (gcc, avr-gcc, etc) and in what order (and with what flags) to compile your code.

There are many Arduino Makefile projects out there that do it all for you.

Majenko
  • 103,876
  • 5
  • 75
  • 133
1

Take a look at platformio.org. It Provides a simple CLI environment to compile, upload and monitor.

Andre Courchesne
  • 676
  • 5
  • 11