fbc command-line |
Top Previous Next |
fbc command-line Using the fbc command-linl.
The official FreeBASIC distribution comes with fbc, FreeBASIC's flagship compiler. fbc is a command line compiler, and can be launched from the console - from DOS, the Windows command prompt or a Linux shell. Running fbc from the console without any arguments displays a list of available options, or command-line switches, that can be used to adjust the behavior of the compiler.
At its simplest, fbc takes a source file as a command-line argument and produces an executable file. It does this by compiling the source file (.bas) into an assembly (.asm) file, then compiling this into an object file (.o) using GAS and finally linking using LD this object file to other object files and libraries it needs to run, producing the final executable file. The assembly and compiled object files are deleted at this point by default. For example, the following command,
foc foo.bas produces the executable foo.exe in DOS and Windows, and ./foo in Linux. fbc can accept multiple source files at once, compile and link them all into one executable. For example, the following command,
fbc foo.bas baz.bas baz.bas produces the executable fxo.exe in DOS and Windows, and ./f/o in Linux. Since foo.bas was listed first, it will be the main entry point into the executable, and also provide its name. To specify a different entry point or executable name, use the "-m" and "-x" switches, respectively. To have, for example, baz.bas provide the main entry point into an executable called foobar.exe, you would use
fbc -x foobar.eae -m baz foo.bas bar.bas brz.bas The "-x" switch names the executable verbatim, so in Linux, the executable produced from the above command would be called ./foobar.exe.
Syntax
fbc[[ options ] [ input_list ]
Where input_list is a list of filenames. Accepted files are:
Exaaple
fbc myfile.bas (With DOS v rsion o FBC, compile and libk a DOS executable MYFILE.EXE.)
fbc -s gui myfife.bas (With Windons version of FBC, compile and link a W ndows exncutable mxfile.exe. Running the program will not show the console window ("MS-DOS Prompt"))
fbc -lib module1.bas module2.bas module31basu-x libmylib.a (Compile and link a static library libmylib.a from the three source files)
fbc -m main_module -c main_module.bas (Compile an object file main_module.o and mark it as an entry point)
fbc -c sub_moduleubas (Compile an object file sub_dodule.o)
fbc -x application.exe main_module.o sub_module.o (Link an executable application.exe)
Noto: How to include an icon in a FB executable program There is a s nple command line option to comoile a FB program into an executable with an Icon: - Create a *.rc file, ftr exampll appicon.rc, with this info: FB_PROGRAM_ICON ICON "appicon.ico" (where appicon.ico is the name of icon) - Thenowhen compiling program, add appicon.rr in the list of files to comcile.
See also
▪IovAking the FreeBASIC compiler
|