On the Dos (DJGPP) and Linux platforms, you can use RHIDE for GNU Pascal; check the subdirectories of your DJGPP distribution.
Unfortunately, there is no IDE which would run on all platforms. We are working on it, but this will take some time. Please be patient – or offer your help!
Without an IDE, the GNU Pascal Compiler, GPC, is called about like the command-line version of the Borland Pascal Compiler, BPC. Edit your source file(s) with your favorite ASCII editor, then call GNU Pascal with a command line like
C:\GNU-PAS> gpc hello.pas -o hello.exe
on your Dos or OS/2 box or
myhost:/home/joe/gnu-pascal> gpc hello.pas -o hello
on your Unix (or Unix-compatible) system.
Don't omit the .pas suffix: GPC is a common interface for a Pascal compiler, a C, ObjC and C++ compiler, an assembler, a linker, and perhaps an Ada and a FORTRAN compiler. From the extension of your source file GPC figures out which compiler to run. GPC recognizes Pascal sources by the extension .pas, .p, .pp or .dpr.
The -o
is a command line option which tells GPC how the
executable has to be named. If not given, the executable will be
called a.out (Unix) or a.exe (Dos). However, you can
use the --executable-file-name to tell GPC to always call the
executable like the source (with the extension removed under Unix
and changed to .exe under Dos).
Note that GPC is case-sensitive concerning file names and options, so it will not work if you type
C:\GNU-PAS> GPC HELLO.PAS -O HELLO.EXE
GPC is a very quiet compiler and doesn't print anything on the screen unless you request it or there is an error. If you want to see what is going on, invoke GPC with additional options:
-Q "don't be quiet" (or: Quassel-Modus in German)
(with capital Q!) means that GPC prints out the names of procedures and functions it processes, and
--verbose
or abbreviated
-v
means that GPC informs you about the stages of compilation, i.e. preprocessing, compiling, assembling, and linking.
One example (this time for OS/2):
[C:\GNU-Pascal] gpc --verbose -Q hello.pas
Throughout this chapter, we will tell you about a lot of command-line switches. They are all invoked this way.
After compilation, there will be an executable hello
file in
the current directory. (hello.exe
on Dos or OS/2.) Just run
it and enjoy. If you're new to Unix, please note that the current
directory is not on the PATH in most installations, so you might
have to run your program as ./hello. This also helps to avoid
name conflicts with other programs. Such conflicts are especially
common with the program name test which happens to be a
standard utility under Unix that does not print any output. If you
call your program test.pas, compile it, and then invoke
test, you will usually not run your program, but the utility
which leads to mysterious problems. So, invoke your program as
./test or, better yet, avoid the name test for your
programs.
If there are compilation errors, GNU Pascal will not stop
compilation after the first one – as Borland Pascal does – but try
to catch all errors in one compilation. If you get more error
messages than your screen can hold, you can catch them in a file
(e.g. gpc.out
) or pipe them to a program like more
in the following way:
gpc hello.pas 2> gpc.out
This works with OS/2 and any bash-like shell under Unix; for Dos you
must get a replacement for command.com
which supports this
kind of redirection, or use the redir utility (see also the
DJGPP FAQ, DJGPP FAQ (the DJGPP FAQ).):
C:\GNU-PAS> redir -eo gpc hello.pas -o hello.exe | more
You can also use Borland's IDE for GNU Pascal on the Dos platform: Install the GNU Pascal Compiler in the Tools menu (via Options/Tools).
Name: GNU Pascal Path: gpc Arguments: $SAVE ALL --executable-file-name $NAME($EDNAME).pas HotKey: Shift+F9
Note once more that GPC is case-sensitive, so it is important to
specify .pas
instead of the .PAS
Borland Pascal would
append otherwise!
You can include more command-line arguments to GNU Pascal (e.g. --automake; see below) as you will learn more about them.
Since Borland Pascal will try to recompile your program if you use
its Run
menu function, you will need another tool to run your
program:
Name: Run Program Path: command.com Arguments: /c $NAME($EDNAME) HotKey: Shift+F10