Re: How to compile program from command line on Linux?

Guillermo Martínez Jiménez via fpc-pascal <[email protected]>
Newsgroups gmane.comp.compilers.free-pascal.general
Organization Burdjia
Message-ID <20241216190025.48762dbb@guillermo-sobremesa>
Use FPC from command line is easy if you're not using the LCL (the
Lazarus Component Library).

If you're using the LCL they explained in the other answers, but if you
just use the RTL then the easiest way is just calling FPC from the
same directory you have the sources:

~$ fpc theprogram

That will compile the program at "theprogram.pas" with default
configuration (the fpc.cfg file).

There are a lot of options you can see just with:

~$ fpc -h | more

In most cases I create directories "src/", "obj/" and "bin/" and then I
use a bash script like this:

#!/bin/sh
# Debug (GDB).
OPTIONS='-O1 -gw3 -gl -vwn -Ci -Cr -Ct -CR -Co -Sa -gh'
# Release.
# OPTIONS='-O3 -CX -XX -Xs -vw'
FLAGS="$OPTIONS -Sh -Si -l"
DIALECT='-MObjFPC'
UNITS='-Fusrc'
OUTPUT='-FUobj -FEbin'
FILE='src/programfile.pas'

FULL="$FLAGS $DIALECT $UNITS $OUTPUT $FILE"
fpc $FULL

I hope this helps.
_______________________________________________
fpc-pascal maillist  -  [email protected]
https://lists.freepascal.org/cgi-bin/mailman/listinfo/fpc-pascal
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.