News:

Masm32 SDK description, downloads and other helpful links
Message to All Guests
NB: Posting URL's See here: Posted URL Change

Main Menu

Creating small FreeBASIC executables

Started by Vortex, January 13, 2013, 03:34:32 AM

Previous topic - Next topic

Vortex

Here is an example project to build a small FreeBASIC executable. It uses my tiny C run-time startup module instead of FB's default library.

Declare Function printf cdecl alias "printf" ( byval as zstring ptr , ... ) as integer

Public Function main cdecl alias "main" ( argc as integer , argv as zstring ptr ptr) as integer

Dim i As Integer

    For i = 0 To argc-1

        printf !"Command-line parameter %d = %s\n" , i , argv[i]
       
    Next

    return 0

End Function


\FreeBasic\fbc -c -r -nodeflibs test.bas

\masm32\bin\polink /SUBSYSTEM:CONSOLE /LIBPATH:\masm32\lib test.o crt0\crt0.lib kernel32.lib msvcrt.lib


The final executable has a size of 1536 bytes.

jj2007

Cute, Erol :t

The -nodeflibs is apparently not needed, with this batch file you also arrive at 1536 bytes:
fbc -c -r %1
\masm32\bin\polink /SUBSYSTEM:CONSOLE %~n1.o \masm32\lib\crt0\crt0.lib \masm32\lib\kernel32.lib \masm32\lib\msvcrt.lib
%~n1.exe MyArg1 MyArg2 MyArg3
pause