Author Topic: Download the executable weight  (Read 4883 times)

Offline mamama

  • Single posting newcomer
  • *
  • Posts: 3
Download the executable weight
« on: October 17, 2011, 11:45:21 am »
Hi, I want to know how I can reduce the weight of the generated executable code:: blocks 10.05. In VC + + for example you can pass parameters to the precompiler a section. Data and. Text of the executable, anyone know if doing that is total in C:: B or have any other solution?

greetings.

Offline Freem

  • Almost regular
  • **
  • Posts: 219
Re: Download the executable weight
« Reply #1 on: October 17, 2011, 01:53:43 pm »
go into compiler options, or build options.
Select optimizations and choose the one you prefer.
Uncheck debugging and profiling options too.

Those options are compiler dependent.

If you want to reduce more, some tools could help you by compressing the exe, adding to it a routine to decompress, load the result directly in memory, and call the program, but I don't remember their names.

Offline mamama

  • Single posting newcomer
  • *
  • Posts: 3
Re: Download the executable weight
« Reply #2 on: October 17, 2011, 03:00:18 pm »
I did what you told me to C:: B and I see no real difference, there must be another solution. I do not see a simple GUI normal on WinAPI 927kb occupy me.

greetings.

Offline oBFusCATed

  • Developer
  • Lives here!
  • *****
  • Posts: 13413
    • Travis build status
Re: Download the executable weight
« Reply #3 on: October 17, 2011, 03:29:17 pm »
Have you used the strip option?
(most of the time I ignore long posts)
[strangers don't send me private messages, I'll ignore them; post a topic in the forum, but first read the rules!]

Offline mamama

  • Single posting newcomer
  • *
  • Posts: 3
Re: Download the executable weight
« Reply #4 on: October 17, 2011, 03:53:08 pm »
Strip all symbols from binary?

Offline Alpha

  • Developer
  • Lives here!
  • *****
  • Posts: 1513
Re: Download the executable weight
« Reply #5 on: October 19, 2011, 02:40:31 am »
Strip all symbols from binary?
Yes.

I assume you are using MinGW; see large executables.

The MinGW flags I have found to produce the smallest binary are "Strip all symbols from binary" and "Optimize generated code for size" under compiler flags,
Code
-fno-rtti
-fno-exceptions
-ffunction-sections
-fdata-sections
-flto
for other compiler options, and
Code
-flto
-Os
-Wl,--gc-sections
-shared-libgcc
-shared-libstdc++
for linker options.  (Note that this will cause the executable to dynamically link to the MinGW run-time libraries.)

Offline Jenna

  • Administrator
  • Lives here!
  • *****
  • Posts: 7255
Re: Download the executable weight
« Reply #6 on: October 19, 2011, 09:59:22 am »
You can pack the executable with something like upx in the postbuild steps.
In the targets post-build step you can put:
Code
upx --best $TARGET_OUTPUT_FILE
Nite: upx has to be in your search-path, otherwise you have to use the full path for it.