Author Topic: QB64 Executable Size  (Read 858 times)

rthorpe

  • Guest
QB64 Executable Size
« on: January 04, 2011, 03:27:16 am »
I remember someone complaining about the size of QB64 executables recently. On my Windows machine they are ~890kB even if the program is very small.

I've found that QB64 is including the C++ debugging information in the executable. This accounts for ~300kB or so.

If you like you can remove these symbols. Doing so means you can't debug using GNU tools, I don't think that feature is even used by QB64 though.

The easiest way to remove the symbols is to use a batch file similar to Galleon's batch file for checking for compilation errors. The following script adds the "-s" option to the arguments sent to the C++ compiler to prevent it from issuing symbols. I'm not sure if all the other arguments used here are correct.

Code: [Select]
@echo off
ECHO.
ECHO Make smaller EXE with no symbols
ECHO.
ECHO Please wait...
ECHO.
cd .\internal\c
.\bin\g -w -Wall -I.\i -I..\..\ -L.\l qbx.cpp libqbx.o -mwindows .\i686-w64-mingw32\lib\libimm32.a -lwinspool -lmingw32 -ln -lmix -limg -lttf -lmn -lSDL -s -o ..\..\no_syms.exe
cd ..\..
ECHO.
ECHO.
PAUSE
The outputted executable is called "no_syms.exe".

On Linux you can remove the symbols with the command "strip -s ExecutableName".
« Last Edit: January 04, 2011, 10:56:54 am by rthorpe »

Dav

  • Hero Member
  • *****
  • Posts: 598
Re: QB64 Executable Size
« Reply #1 on: January 04, 2011, 07:23:30 am »
Nice tip, rthorpe.  This reduced my EXE from 933k to 550k.  

Note to others:  The BAT creates an EXE called no_syms.exe.

- Dav

« Last Edit: January 04, 2011, 07:30:48 am by Dav »
(Visit Dav's Qbasic Site) (Grab my IDE)

Clippy

  • Hero Member
  • *****
  • Posts: 17408
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: QB64 Executable Size
« Reply #2 on: January 04, 2011, 07:29:58 am »
First off, it's not MY batch file. Galleon supplied it so that we could try to determine compiler errors.

So you add the -s and then what? I tried adding the filename, but nothing happened...
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

rthorpe

  • Guest
Re: QB64 Executable Size
« Reply #3 on: January 04, 2011, 07:41:09 am »
Clippy,

I didn't know Galleon supplied that batch file.

> So you add the -s and then what? I tried adding the filename, but nothing happened...

It's to be used in the same way as the error batch file. Open a Basic program and compile it from QB64. Then run the batch file straight afterwards, it will recompile the C++ that QB64 generated but without the debugging symbols. It will create an executable called no_syms.exe which does the same thing as the original, but the file is smaller.

Clippy

  • Hero Member
  • *****
  • Posts: 17408
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: QB64 Executable Size
« Reply #4 on: January 04, 2011, 07:49:13 am »
THE CODE LINE DOESN'T MATCH THE ONE I HAVE!

I see that you posted a NEW ONE. WHERE did you come up with that?

WTF!
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

Clippy

  • Hero Member
  • *****
  • Posts: 17408
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: QB64 Executable Size
« Reply #5 on: January 04, 2011, 08:29:21 am »
I'm gonna see if I can't have your code make a new EXE with a similar name. Like add something to the original EXE name to alter it slightly.

Where exactly is the new EXE file created? I have to go out for a bit so let me know.

Thanks,

Ted
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

rthorpe

  • Guest
Re: QB64 Executable Size
« Reply #6 on: January 04, 2011, 08:47:58 am »
While I was looking at this I noticed something else.  QB64 itself and all the programs from MinGW that come with it still have their debugging symbols too. If Galleon wants to reduce the bandwidth used by the updates then removing those symbols may be useful, there's probably a few MB overall between the 10 or so EXEs that QB64 comes with.


Clippy,

> I'm gonna see if I can't have your code make a new EXE with a similar name. Like add something to the original EXE name to alter it slightly.

That would be a good idea.

> Where exactly is the new EXE file created?

See the other thread.

Clippy

  • Hero Member
  • *****
  • Posts: 17408
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: QB64 Executable Size
« Reply #7 on: January 04, 2011, 09:08:42 am »
Mr Thorpe,

I have ALREADY CHASED enough of YOUR THREADS!

1) You post that "Clippy's" code is no longer valid and post your new code.

2) You tell people in ANOTHER post that all they have to do is add -s to "Clippy's" code to get smaller EXE files!

YOU WERE USING YOUR CODE! NOT MINE!  NOT GALLEON'S!

Perhaps you can see why I am somewhat confused...  :P
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

rthorpe

  • Guest
Re: QB64 Executable Size
« Reply #8 on: January 04, 2011, 09:16:35 am »
> Perhaps you can see why I am somewhat confused...

Yes, I do. I apologise for the confusion, the .bat file at the beginning of this thread is different from the compilation error batch file.

Clippy

  • Hero Member
  • *****
  • Posts: 17408
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: QB64 Executable Size
« Reply #9 on: January 04, 2011, 09:29:05 am »
Then PLEASE EDIT your original post accordingly. We don't need any more confusion than there already is. Just say that YOU made a way to do it and leave it at that.

I will have to wait for Galleon's answer about the ERROR file code.

Ted
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

Clippy

  • Hero Member
  • *****
  • Posts: 17408
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: QB64 Executable Size
« Reply #10 on: January 04, 2011, 12:16:27 pm »
I tried the Symbol BAT that I call "64stripper" and it reduced an 867K file to 487K. A 44% reduction! I'm impressed! I KNEW that there was a lot of JUNK in them when I read them in a binary Editor.

I also found a way to reduce the size when I added Icons to some QB64 program EXEC's. Resource Hacker reduced the size considerably when it recompiled them.

Now I gotta figure a way to get your code to name each EXE to something similar to the original EXE.

Nice idea!

Ted

QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

rthorpe

  • Guest
Re: QB64 Executable Size
« Reply #11 on: January 05, 2011, 10:14:50 am »
> Now I gotta figure a way to get your code to name each EXE to something similar to the original EXE.

I had a look into this.

The problem is that the C++ output that QB64 creates is designed to be internal to QB64, not to be tinkered with :). QB64 doesn't always put the exe name into a file.

As far as I can see the only way to do it is to make a batch file that does "QB64 -c something.bas" first. Then the C++ code can be recompiled with -s using the commands from batch file I gave earlier. Then the name "something.bas" can be used to to derive a suitable EXE name. That's a bit clumsy because it means compiling the C++ twice.

Clippy

  • Hero Member
  • *****
  • Posts: 17408
  • I LOVE π = 4 * ATN(1)    Use the QB64 WIKI >>>
    • Pete's Qbasic Site
Re: QB64 Executable Size
« Reply #12 on: January 05, 2011, 12:45:19 pm »
Naw, I was just going to either copy or rename it. I tried dropping the large EXE file into it to get the name there, but it won't let me do that. It HAS to be done from a separate procedure apparently.

I just sent Galleon an email about this stuff and I'm hoping that he can incorporate the -s into the actual compilation rather than forcing us to recompile every program.

I also am trying to get rid of those two TXT files that pop up every time you run a program. Dav found a way to edit a file so that those files are not created. I hope Galleon can get rid of them unless he has a reason not to.

Since he is on summer break this month it might be a good time to address these issues.

Ted
QB64 WIKI: Main Page
Download Q-Basics Code Demo: Q-Basics.zip
Download QB64 BAT, IconAdder and VBS shortcuts: QB64BAT.zip
Download QB64 DLL files in a ZIP: Program64.zip

Galleon

  • Administrator
  • Hero Member
  • *****
  • Posts: 5061
  • QB Forever
Re: QB64 Executable Size
« Reply #13 on: January 06, 2011, 06:21:05 am »
Can anyone think of a reason I shouldn't add -s to the GCC C++ compile?

Otherwise, I agree that we definitely should. I always suspected the EXEs were a bit too bloated, even thought they had everything including a function to 'add one' to numbers.
Something old... Something new... Something borrowed... Something blue...

rthorpe

  • Guest
Re: QB64 Executable Size
« Reply #14 on: January 06, 2011, 06:46:38 am »
The only problem I can think of is non-standard uses of executable files.  Suppose for copy protection you force a secret binary section into an exe, by using a custom binary object file for example.  The linker could strip that out with -s.  I can't see that problem affecting QB64 though.