PROGRAMMING > Freebasic

Making tiny FB executable programs

<< < (7/8) > >>

ninogenio:
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.

neumanix:
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 :)

ninogenio:
yeah the rnd errors are because rnd belongs to freebasic not sure about glfw but ptc stuff should be possible i think.

coderJeff:
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: ---'' 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
--- End code ---

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.

Shockwave:
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!).

Navigation

[0] Message Index

[#] Next page

[*] Previous page

Go to full version