Friday, April 28, 2017

Executable sizes

I was curious about the size of executables generated by different compilers in C and C++. So I made a small program that reads a list of numbers from stdin and prints the sum, then compiled it using several compilers and settings. You can find below the results.


Language Operating system Compiler Runtime dependencies Executable size in bytes
C++ Windows 10 Visual C++ 2017 Dynamic 10,752
C++ Windows 10 Visual C++ 2017 Static 290,816
C Windows 10 Visual C++ 2017 Dynamic 10,752
C Windows 10 Visual C++ 2017 Static 140,288
C++ Ubuntu 16.10 GCC 6.2 Dynamic 8,960
C++ Ubuntu 16.10 GCC 6.2 Static 2,202,384
C++ Ubuntu 16.10 GCC 6.2 Static+strip 1,771,096
C Ubuntu 16.10 GCC 6.2 Dynamic 8,528
C Ubuntu 16.10 GCC 6.2 Static 915,608
C Ubuntu 16.10 GCC 6.2 Static+strip 844,784
C++ Ubuntu 16.10 clang 4.0.0 Dynamic 8,984
C++ Ubuntu 16.10 clang 4.0.0 Static 2,202,320
C++ Ubuntu 16.10 clang 4.0.0 Static+strip 1,771,056
C Ubuntu 16.10 clang 4.0.0 Dynamic 8,352
C Ubuntu 16.10 clang 4.0.0 Static 915,528
C Ubuntu 16.10 clang 4.0.0 Static+strip 844,744


The command line used:

clang++ -o main Main.cpp -O3 -static -static-libgcc -static-libstdc++

clang -o main Main.c -O3 -static -static-libgcc

No comments:

Post a Comment