c - MinGW gcc vs linux gcc executable size -


i wrote small c program

#include <stdio.h>  int main() {     int = 0;     while (i < 10){         printf("%i", i);         i++;     }  } 

if compile mingw gcc executable 59kb if compile linux gcc, via ubuntu on windows shell, executable 9kb. 50kb seems lot of data... why this?

according mingw wiki, debugging information can included libraries linked executable. can exclude debugging information executable, gcc "-s" option or "strip" command.

support "gnu style" or "ms style" printf format seems 1 of differences between mingw stdio , gnu c library stdio.


mingw

#>  gcc --version gcc.exe (gcc) 5.3.0  #>  gcc -o printf_gcc_mingw.exe printf.c #>  gcc -s -o printf_gcc_strip_mingw.exe printf.c #>  du -ch *.exe 59k     printf_gcc_mingw.exe 45k     printf_gcc_strip_mingw.exe 

mingw-w64

#>  gcc -o printf_gcc.exe printf.c #>  gcc -s -o printf_gcc_strip.exe printf.c #>  gcc --version gcc (tdm64-1) 5.1.0 #>  dir *.exe                132,613 printf_gcc.exe             16,896 printf_gcc_strip.exe      #>objdump -x printf_gcc_strip.exe      dll name: msvcrt.dll     vma:  hint/ord member-name bound-to     85ca       55  __c_specific_handler     85e2       78  __dllonexit     85f0       81  __getmainargs     8600       82  __initenv     860c       83  __iob_func     861a       91  __lconv_init     862a       97  __set_app_type     863c       99  __setusermatherr     8650      116  _acmdln     865a      123  _amsg_exit     8668      141  _cexit     8672      252  _fmode     867c      330  _initterm     8688      438  _lock     8690      610  _onexit     869a      820  _unlock     86a4     1031  abort     86ac     1049  calloc     86b6     1062  exit     86be     1081  fprintf     86c8     1088  free     86d0     1099  fwrite     86da     1146  malloc     86e4     1154  memcpy     86ee     1163  printf     86f8     1184  signal     8702     1205  strlen     870c     1208  strncmp     8716     1240  vfprintf 

visual studio 2015

#>  cl /md printf.c /link  /out:printf_vs.exe #>  dir *.exe                  9,728 printf_vs.exe  #>printf_vs.exe 0123456789    

Comments

Popular posts from this blog

java - SSE Emitter : Manage timeouts and complete() -

jquery - uncaught exception: DataTables Editor - remote hosting of code not allowed -

java - How to resolve error - package com.squareup.okhttp3 doesn't exist? -