using arduino ide to program mega w/ code built on command line

i was able to build a commercial program consisting of 27 .c/h files, producing a .elf and .hex file

can i use the arduino IDE to program it into a arduino mega or just use avrdude?

Is it possible? Yes. For example, here is a hack we did to make the Arduino IDE upload a .hex file to a Pro Micro to turn it into a UPDI programmer:

Is it worth doing just for a one-off upload of a .hex file? No. Just use avrdude. You can use the Arduino IDE to help generate your avrdude command though:

  • File > Preferences
  • Check the box next to "Show verbose output during: > upload".
  • Click "OK".
  • Upload any sketch to your target board.
  • After the upload finishes, scroll up the black console window at the bottom of the Arduino IDE window until you see the avrdude command the Arduino IDE used to upload the sketch. Copy and paste this into a text editor.
  • Change the compiled sketch's .hex filename to the filename of the file you want to upload.
  • If the paths contain spaces, wrap them in quotes.
  • Run the modified command from the command line.

thanks

i eventually realized i can look at the command lines the IDE generates and see the options to avrdude. In particular, i needed to see the programmer type, wiring.