Author Topic: Making tiny FB executable programs  (Read 15458 times)

0 Members and 1 Guest are viewing this topic.

Offline Rbz

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 2757
  • Karma: 493
    • View Profile
    • https://www.rbraz.com/
Re: Making tiny FB executable programs
« Reply #20 on: July 09, 2007 »
Karma boost!
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Making tiny FB executable programs
« Reply #21 on: July 10, 2007 »
i followed all above steps and so far so good now im on to the platform sdk will the newer windows sdk work ok? and its over a gigs worth of download!

i already have visual studio so do i still need the platfom sdk?
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Making tiny FB executable programs
« Reply #22 on: July 10, 2007 »
Any version of the SDK should do.  Visual Studio will have them in, I think.
Mine are here
C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Lib

Jim
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Making tiny FB executable programs
« Reply #23 on: July 10, 2007 »
phew thanks jim they are there!  :) i thought i was going to be on the think end of a huge download.
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Making tiny FB executable programs
« Reply #24 on: July 10, 2007 »
im getting a linker error now in the form of

Code: [Select]
C:\Documents and Settings\nino\Desktop\trinity>Fbc.exe -c trinity.Bas

C:\Documents and Settings\nino\Desktop\trinity>\MASM32\BIN\ml /c /coff stub.asm

Microsoft (R) Macro Assembler Version 6.14.8444
Copyright (C) Microsoft Corp 1981-1997.  All rights reserved.

 Assembling: stub.asm

C:\Documents and Settings\nino\Desktop\trinity>crinkler /SUBSYSTEM:WINDOWS /OUT:
trinity.exe /LIBPATH:"C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\
Lib" kernel32.lib user32.lib trinity.o stub.obj
Crinkler 1.0a (Jan  7 2007) (c) 2005-2007 Aske Simon Christensen & Rune Stubbe

Target: trinity.exe
Subsystem type: WINDOWS
Compression mode: FAST
Hash size: 100 MB
Hash tries: 20
Order tries: 0
Transforms: NONE
Replace DLLs: NONE
Range DLLs: NONE

loading:
  kernel32.lib  user32.lib  trinity.o  stub.obj

 : fatal error: LNK   0: could not find symbol '_ChoosePixelFormat@8'


C:\Documents and Settings\nino\Desktop\trinity>pause
Press any key to continue . . .

have i missed a lib out?
Challenge Trophies Won:

Offline Jim

  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 5301
  • Karma: 402
    • View Profile
Re: Making tiny FB executable programs
« Reply #25 on: July 10, 2007 »
You need to add opengl32.lib glu32.lib gdi32.lib to the link.

Jim
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Making tiny FB executable programs
« Reply #26 on: July 10, 2007 »
doh of course,

cheers jim the best i can get the trinity example to is 1028 bytes thats with rearanging the code and messing around with crinkler.
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Making tiny FB executable programs
« Reply #27 on: July 10, 2007 »
hey jim i had a little mess about with your example and the best i could get was 1066 but one thing i noticed was streight away it was linking to 1076 bytes so i guess i must be getting slightly better compresion using these switches.

crinkler /SUBSYSTEM:WINDOWS /ORDERTRIES:10000 /HASHTRIES:500 /OUT:trinity.exe /LIBPATH:"C:\Program Files\Microsoft Visual Studio 8\VC\PlatformSDK\Lib" kernel32.lib user32.lib trinity.o stub.obj opengl32.lib glu32.lib gdi32.lib
Challenge Trophies Won:

Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Making tiny FB executable programs
« Reply #28 on: July 10, 2007 »
Thanks Jim for the excellent help as always! K+

I will have to install 1.7 I think. I don't use the laptop anymore for programming so there's no reason not to update any more I guess.
Shockwave ^ Codigos
Challenge Trophies Won:

Offline neumanix

  • ZX 81
  • *
  • Posts: 10
  • Karma: 3
    • View Profile
Re: Making tiny FB executable programs
« Reply #29 on: August 30, 2007 »
I tried this with a couple of programs, one using tinyptc and one using glfw. On both attempts I get a linker error that says "could not find symbol WinMainCRTStartup".
What am i missing here?!

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Making tiny FB executable programs
« Reply #30 on: August 30, 2007 »
i think you might have to rework some of the steps to get tinyptc or glfw working with this as it was geard towards aulds 1k ogl framework also remember with this you cant youse any of fbs commands as jim stubbs them off to get tiny fb executables.
Challenge Trophies Won:

Offline neumanix

  • ZX 81
  • *
  • Posts: 10
  • Karma: 3
    • View Profile
Re: Making tiny FB executable programs
« Reply #31 on: August 30, 2007 »
ok, I solved the problem that I had... I didn't undertand that there has to be a function called "WinMainCRTStartup" in your code.
But now I get other linking errors, some kind of rnd stuff. I guess that's because I used RND which is a freebasic command.
I'll try some more to get the glfw code to work. I'll need a static glfw.lib I guess, gonna try to figure out how to make one :)

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Making tiny FB executable programs
« Reply #32 on: August 30, 2007 »
yeah the rnd errors are because rnd belongs to freebasic not sure about glfw but ptc stuff should be possible i think.
Challenge Trophies Won:

Offline coderJeff

  • ZX 81
  • *
  • Posts: 4
  • Karma: 3
    • View Profile
Re: Making tiny FB executable programs
« Reply #33 on: October 23, 2007 »
Here's a trick that makes small exes.  It won't be as small as crinkler,
but it is fairly easy to set-up, and you need no other resources except what's packaged with fbc 0.18.2.

Assume that FreeBASIC is installed at:
C:\FreeBASIC\

and that our "trick" is installed at:
F:\tinyfb\

Create some directories like so:
mkdir F:\tinyfb\
mkdir F:\tinyfb\bin\
mkdir F:\tinyfb\bin\win32\
mkdir F:\tinyfb\lib\
mkdir F:\tinyfb\lib\win32\


Copy two files from C:\FreeBASIC\ to our new directory:
copy C:\FreeBASIC\bin\win32\i386pe.x F:\tinyfb\bin\win32\i386pe.x
copy C:\FreeBASIC\bin\win32\ld.exe F:\tinyfb\bin\win32\ld.exe


Go into F:\tinyfb\lib\win32\ and create some empty object files just to make the fbc.exe command line happy:
F:
cd \tinyfb\lib\win32\
echo REM > crt2.bas
fbc -c crt2.bas
copy crt2.o crtbegin.o
copy crt2.o crtend.o
copy crt2.o fbrt0.o
cd ..\..


Now let's create our example:
Code: [Select]
'' hello.bas

#include once "windows.bi"

function WinMainCRTStartup cdecl _
  alias "WinMainCRTStartup" () as integer

  Messagebox( 0, "Small EXE example", "Hello", MB_OK )
  return 0

end function

Finally, the last two steps are to compile, then to link our exe:
fbc -c hello.bas
fbc hello.o -s gui -prefix F:\tinyfb -p "C:\FreeBASIC\lib\win32"


The "-prefix F:\tinyfb" option tells fbc where to pick up the extra bits of code.  Since we provided empty object files, no size is added.  The "-p" options tells fbc where to find all the import libs.

For me, this compiles to 2560 bytes. 

I know this is an old-ish thread, but I meant to post something here after I saw this, but never did.

Also, if you are making a Windows App and are planning to use MSVCRT, but want to make sure you don't get any fb-runtime stuff, the fbc command line option '-nodeflibs' was updated not to include 'fbrt0.o'.  Don't know if that's any help, but thought I would mention.


Offline Shockwave

  • good/evil
  • Founder Member
  • DBF Aficionado
  • ********
  • Posts: 17409
  • Karma: 498
  • evil/good
    • View Profile
    • My Homepage
Re: Making tiny FB executable programs
« Reply #34 on: October 23, 2007 »
Some good tips there CoderJeff :) Have some good Karma for that and welcome to the forum (I know you have been registered a while, but it's always nice to see people posting, especially good stuff like that!).
Shockwave ^ Codigos
Challenge Trophies Won:

Offline ninogenio

  • Pentium
  • *****
  • Posts: 1668
  • Karma: 133
    • View Profile
Re: Making tiny FB executable programs
« Reply #35 on: October 23, 2007 »
k+ coderjeff,

its great to hear of other ways size can be reduced in fb. nice one!
Challenge Trophies Won:

Offline rain_storm

  • Here comes the Rain
  • DBF Aficionado
  • ******
  • Posts: 3088
  • Karma: 182
  • Rain never hurt nobody
    • View Profile
    • org_100h
Re: Making tiny FB executable programs
« Reply #36 on: October 25, 2007 »
Okay I finally got this to work (Just Jim's tiny.exe) it is really my first time working with a commandline tool
now I have a question
Is it better to use OpenGL or tinyptc for creating small exe's if all I'm asking from them is to display a buffer of rgb values (like a xor texture or plasma effect)

Challenge Trophies Won:

Offline coderJeff

  • ZX 81
  • *
  • Posts: 4
  • Karma: 3
    • View Profile
Re: Making tiny FB executable programs
« Reply #37 on: October 25, 2007 »
Thanks Shockware, ninogenio.  Yeah, I lurk in here from time to time.  You guys put out some impressive stuff.  And use FreeBASIC in ways nobody else is even thinking about.  It's always a pleasure to visit.