Questuion about size after compiling


I have a set of files. Compiled with gcc49 under FreeBSD. The default makefile, created by me. Well, that's not the problem.

Ok, I decided to compile with CMake.

<ul><li>When compiling with default makefiles(gcc49) output target size is : 5 MB</li> <li>When compiling with cmake(gcc49, same flags as in makefile default) output target is : 12 MB</li> </ul>

My question is, why are so big differences in size.

I want the file to end, to be as small size, it was ok 5mb.

What should I do to make my 5mb file( with cmake)

THX all


You are invoking the compiler with different options in the two cases.

CMake already sets a bunch of compiler and linker options for you that best suit your project. Unfortunately, if you are new to CMake it is not always obvious to see why a particular option is being set and how to change it idiomatically.

For the Makefile generator, to find out which options CMake passes to the compiler you can set the VERBOSE environment variable when invoking make on the shell:

$ VERBOSE=1 make

Compare the commands used by CMake to the ones that you use when building manually. Once you identified the culprit, do some further research on how to best change that particular build option with CMake.


CMake builds <strong><em>debug</em></strong> configuration per default. If you haven't switched to <strong><em>release</em></strong> the binaries are build as debug resulting an increased size.

You can test again <strong><em>release</em></strong>, eg.:

cd release_dir cmake -DCMAKE_BUILD_TYPE=Release .. make


  • AWS | Syntax error in module': invalid syntax
  • cmake: problems specifying the compiler
  • Installing PySide - OSX
  • Performance of System.IO.ReadAllxxx / WriteAllxxx methods
  • Gnuplot multiplot: Convenient method for creating more complex layouts
  • How to make Java compiler generate line numbers in compiled code
  • iterparse fails to parse a field, while other similar ones are fine
  • How to filter the baselines(UCM) alone from describe command?
  • Performance difference between accessing local and class member variables
  • Why are `colMeans()` and `rowMeans()` functions faster than using the mean function with `lapply()`?
  • Clion & CMake. How To Add Library (*.so)
  • App Memory Usage differs between Devices
  • Unable to use dot layout (graphviz as a library)
  • WebApp in AppServices vs CloudService
  • Cannot connect to native local socket on android 5.1
  • How do i find all references to a user control
  • How to initialize context? [closed]
  • Using SWIG with a build system [closed]
  • Granting permissions to Azure Active Directory Web Application automatically
  • Action Pack components in Rails
  • Xaml, wpf image position and crop issue
  • Is it possible to run clang with llc flags
  • In matplotlib, how do you change the fontsize of a single figure?
  • Clear activity stack before launching another activity
  • Tell Git to stop prompting me for conflicts when none really exist?
  • Entity Framework Code First TPC Inheritance Self-Referencing Child Class
  • SharedPreferences or SQLite Database?
  • Is there a way to do normal logging with EureakLog?
  • Atlas images wrong size on iPad iOS 9
  • Ajax Loaded meta Tags
  • Xamarin Forms - UWP Fonts
  • Using $this when not in object context
  • Uncaught Error: Could not find module `ember-load-initializers`
  • Arrow is showed instead of the material design version hamburger icon. Why doesn't syncState in
  • Run Powershell script from inside other Powershell script with dynamic redirection to file
  • Arrays break string types in Julia
  • Load html files in TinyMce
  • How can I get HTML syntax highlighting in my editor for CakePHP?
  • coudnt use logback because of log4j
  • Programmatically clearing map cache