Arduino IDE hex file size

Hi, I'm using eclipse to compile code for the Yun. Using verbose mode in the actual Arduino IDE I've captured most of the build commands and options, and set them up in eclipse. But... My final program size for a trivial hello program is 18k, but in the IDE it's only 4k. The elf files are more or less the same size. I have set eclipse to generate a listing file, where I can see the .text Section is indeed 18k.

Before I go much further, and try to coax a listing file out of the IDE, does anyone know of any obvious reason why the two output images might differ so much in size?


Are you sure you used the -fdata-sections and -ffunction-sections on ALL compilations, including things in the library? And passed the -Wl,--gc-sections to the linker? These options delete functions and global data that are unused in your program.

In addition, make sure the same optimization flags are used. I think Arduino tends to use -Os, but I may be mis-remembering.

Hi Micahel, many thanks for replying. You pointed me in the right direction. It was a problem with Linker flags. I had noted all of the flags that the Ardiono IDE uses for linking, including -gc-sections, but the Eclipse IDE was arranging all of the flags in it's own merry way. I dumped the various Eclipse input panels for linking, and hard coded a set of flags on the "Export mode" setting. I am now getting the same output images from Eclipse as from the Arduino.

Cheers, Con

Great, I'm glad it was simple to fix.