this image contains text
Written by XQTR of Another Droid BBS andr01d.zapto.org:9999
This is a small guide for the FreePascal Compiler FPC. Its not mended
to be a complete or advanced guide, but a guide for beginners and above,
programmers who want to know fpc better. So lets begin...
::t h e c o m p i l e r::
First of all lets talk about the compiler its self. When you want to
compile a program you usually do so with the fpc command. Actually fpc is
a mask for other binaries, like ppc386, ppcx64 and others. Depending
the system you have, if its a 32bit or 64bit, or you are using Windows
instead of Linux etc fpc executes the appropriate binary for that system.
Lets say, that its a cross system way to execute the correct
compiler/binary. In some cases, its more convenient to execute the right
binary yourself instead of letting fpc to do that. For example. I use a
linux machine and i cross compile binaries for both 32bits and 64bits.
Instead of executing fpc with the appropriate switches to compile the
source to 32bit, i just use ppc386. When i want to compile for the 64bit
system, i am executing ppcx64. The trick is that, i dont have to change
any other switches, so the rest of the command line is the same. Useful
or not, you decide.
::s w i t c h e s::
FreePascal compiler has many switches to use with, that in some cases,
are very helpful and make a difference. Below are some, that i use and
are helpful or important to know. Some of them have equivalent
directives, that you can put inside the source code of your program. But
in some cases is more useful to use the switches instead of the
directives. This way, you dont have to change the source code and make
quick tests and debugging.
-CPPACKRECORDy y record packing: 0 or DEFAULT or NORMAL, 1, 2, 4,
8, 16 and 32
Its the same with the PACKRECORDS directive. Use the switch for quick
testing.
-Fu, -Fo, -Fi
Use these switches to let the compiler know, where to find extra files
you use. Fu is for Units, Fo is for objects and Fi is for include files.
This way you dont have to edit the fpc.cfg file if you want to add
something just in a harry, testing, debugging... or you are too lazy to
edit the fpc.cfg file... :p
-gl
This switch is magic : its the alpha and omega of debugging your code.
In a simple way, this switch will enable fpc to show you the exact line
in your code, where a crash happened. So if there is a bug in your code
and the program crashes, fpc will tell you that its in the line number
xxx and also display some of the code. The disadvantage of this, is that
it will make your binary file, larger. So use it only when you debug your
program. In the final compilation use the one below...
-Xs Strip all symbols from executable
My favorite switch... you dont have to know its thing... but know only
this... use it to decrease the size of your binary file, when you are
ready and want to make a package.
-Mfpc, -Mobjfpc, -Mdelphi, -Mtp
Its the same with the MODE directive. It tells the compiler which
version of pascal to use... delphi, turbo pascal, free pascal etc. Very
useful for me...
-Sc
FreePascal also supports operators like C *,+,/ and -, so if you
came from the C side of the world, you can use them also. Not many
people know that... but now you do!!!
-Px Set target CPU
arm,avr,i386,jvm,m68k,mips,mipsel,powerpc,powerpc64,sparc,x8664
You can use this switch to cross compile in different platforms, or
execute the right binary see at the top of the text your self. I dont
use it at all... :p
-vx Verbose thing...
It has many options to use this switch. Go read the manual of FPC. It
will help you a lot in debugging your software.
This is only a small portion of the switches that FPC uses, but i think
that will cover most basic and average programmers. Hope you find it
useful and you will use them.
This is a small guide for the FreePascal Compiler FPC. Its not mended
to be a complete or advanced guide, but a guide for beginners and above,
programmers who want to know fpc better. So lets begin...
::t h e c o m p i l e r::
First of all lets talk about the compiler its self. When you want to
compile a program you usually do so with the fpc command. Actually fpc is
a mask for other binaries, like ppc386, ppcx64 and others. Depending
the system you have, if its a 32bit or 64bit, or you are using Windows
instead of Linux etc fpc executes the appropriate binary for that system.
Lets say, that its a cross system way to execute the correct
compiler/binary. In some cases, its more convenient to execute the right
binary yourself instead of letting fpc to do that. For example. I use a
linux machine and i cross compile binaries for both 32bits and 64bits.
Instead of executing fpc with the appropriate switches to compile the
source to 32bit, i just use ppc386. When i want to compile for the 64bit
system, i am executing ppcx64. The trick is that, i dont have to change
any other switches, so the rest of the command line is the same. Useful
or not, you decide.
::s w i t c h e s::
FreePascal compiler has many switches to use with, that in some cases,
are very helpful and make a difference. Below are some, that i use and
are helpful or important to know. Some of them have equivalent
directives, that you can put inside the source code of your program. But
in some cases is more useful to use the switches instead of the
directives. This way, you dont have to change the source code and make
quick tests and debugging.
-CPPACKRECORDy y record packing: 0 or DEFAULT or NORMAL, 1, 2, 4,
8, 16 and 32
Its the same with the PACKRECORDS directive. Use the switch for quick
testing.
-Fu, -Fo, -Fi
Use these switches to let the compiler know, where to find extra files
you use. Fu is for Units, Fo is for objects and Fi is for include files.
This way you dont have to edit the fpc.cfg file if you want to add
something just in a harry, testing, debugging... or you are too lazy to
edit the fpc.cfg file... :p
-gl
This switch is magic : its the alpha and omega of debugging your code.
In a simple way, this switch will enable fpc to show you the exact line
in your code, where a crash happened. So if there is a bug in your code
and the program crashes, fpc will tell you that its in the line number
xxx and also display some of the code. The disadvantage of this, is that
it will make your binary file, larger. So use it only when you debug your
program. In the final compilation use the one below...
-Xs Strip all symbols from executable
My favorite switch... you dont have to know its thing... but know only
this... use it to decrease the size of your binary file, when you are
ready and want to make a package.
-Mfpc, -Mobjfpc, -Mdelphi, -Mtp
Its the same with the MODE directive. It tells the compiler which
version of pascal to use... delphi, turbo pascal, free pascal etc. Very
useful for me...
-Sc
FreePascal also supports operators like C *,+,/ and -, so if you
came from the C side of the world, you can use them also. Not many
people know that... but now you do!!!
-Px Set target CPU
arm,avr,i386,jvm,m68k,mips,mipsel,powerpc,powerpc64,sparc,x8664
You can use this switch to cross compile in different platforms, or
execute the right binary see at the top of the text your self. I dont
use it at all... :p
-vx Verbose thing...
It has many options to use this switch. Go read the manual of FPC. It
will help you a lot in debugging your software.
This is only a small portion of the switches that FPC uses, but i think
that will cover most basic and average programmers. Hope you find it
useful and you will use them.
log in to add a comment.