Cross-Platform Development with Free Pascal 2.2.0

Recently, Free Pascal (FPC) version 2.2.0 was released. This open source Pascal compiler has – since its initial release in 1993 – grown to be one of the most sophisticated open source compilers available today. Daily, more programmers discover FPC and develop their applications in Object Pascal. Specifically, the development of Lazarus has contributed to this phenomenon: Lazarus is a graphical open source IDE for FPC, with an extensive tool kit to design graphical (GUI) applications.

What is FPC’s strength?

For many programmers, the renewed interest in Pascal is surprising. Many
think of Pascal as an old language, no longer used, which has lost the battle with C a long time ago. Nevertheless, FPC has enough features to make it the language of choice for programmers.

Cross Platform

The biggest advantage of FPC is that it is cross-platform. The development
of this compiler has been focused on this aspect ever since the start of the
2.0 series.

This feature removes the need for laborious writing of complicated
Makefiles, which differ per platform, and which need to be generated with
tools like autoconf and configure: The programmer does not need to look for
all kinds of libraries: copying the compiler and the sources of the project
to another platform is sufficient for porting to a new system. Obviously,
cross compiling from one platform (say, Linux) to another (Windows is a
popular target) is also possible.

The reason Free Pascal code is portable is simple: it offers a large set of
cross-platform standard routines, bypassing the differences between Posix
and Windows API’s. While those can be simulated on other platforms, these
simulations require cumbersome libraries and installations, and often the
programs have a strange look-and-feel on the non-native platforms.

The Free Pascal compiler comes with a rich set of code libraries: The RTL
(Run-Time Library) provides basic functionality such as file-access,
classes, string manipulation and RTTI (Run-Time Type Information) for
streaming. The FCL (Free Class Library) is an object oriented library that
takes care of XML, Web programming, database access, image manipulation or a test-unit framework. As long as a programmer uses these libraries and
refrains from using system-dependent APIs, his program will not only run on
Linux, but also on Windows, Free BSD, Mac OS X, Windows CE and more.

It is self-evident that direct references to operating specific directories
such as ‘c:\program files’ or a configuration file in ‘/etc/myprog.cfg’,
are not cross-platform.
Using the FPC routines (for instance the TRegistry class) will take care of
these operating system details: The FCL knows where and how each system
stores configuration data. This almost completely removes the need for
system-specific API calls.

Graphical (GUI) applications

Graphical (Desktop) applications are the norm these days. Those are not a
problem: the IDE (Integrated Development Environment) Lazarus is designed
with the same principles in mind as when designing FPC: The LCL (Lazarus
Class Library) delivered with Lazarus makes it possible to develop desktop
applications that use the standard Windows 32 or 64 API. On Linux GTK 1 or 2 is used, and both a Qt and Carbon native layer are nearing their completion.

Using Lazarus, an application can be developed on Linux, and it will use
GTK. All that is needed to make a Windows version of this application is
supplying a compiler option: A recompile will then produce a windows
executable that works directly on any Windows version – without the need for
installing extra libraries. All that is required for this is a standard
Lazarus installation.

64-bits Windows

Compiling from Windows to Linux is slightly more difficult: the compiler
needs the GNU linker to compile ELF binaries, and it needs to have a copy of
all needed libraries available. Yet the principle remains the same. To
produce windows binaries, FPC has an internal linker. This enables the
compiler to generate 64-bit Windows binaries, when the GNU utilities do not
yet have this ability. This makes FPC and Lazarus the first big open-source
compiler and IDE for Win64.

New features for Object Pascal

In the past, the FPC added several new features to the pascal language, such
as operator overloading – later also implemented by commercial compilers.
New in version 2.2 is the experimental support for generics (templates).
This can be useful when programming e.g. list classes.


FPC is a fast compiler: FPC compiles code roughly 7 times faster than for
instance GCC. This may seem to be of little importance, but it cuts down
development time. The speed of the generated code is comparable to the GCC compiler: according to the Shootout benchmarks, the FPC 2.0.4 code is 30% slower code than GCC. In contrast, FPC code uses less memory than GCC
generated code. Compared to interpreted languages, one sees that FPC code
executes 50 times faster than e.g. Ruby. The difference with PHP and Java is
smaller, but these use 14 (PHP) to 17 (Java) times more memory than FPC

One can wonder whether the speed of benchmarks says anything about real
(graphical) applications. Comparing the response of the popular Java IDE
Eclipse with the response of Lazarus will quickly convince one of the
difference. Native code remains faster than interpreted and JIT languages,
even when pre-compiled. Native code uses less memory, and is easier to
install, since no extras need to be installed on the computer of the


As remarked earlier on, Free Pascal is shipped with the RTL and FCL code
libraries. The FCL comes with components for accessing databases such as
Oracle, Firebird, MySQL, SQLite, PostgreSQL and any ODBC enabled database.
It also contains code for XML, Web Programs (CGI and Apache modules) or
access to graphical libraries such as SDL and OpenGL. Lots of Delphi
components are directly usable with Free Pascal. The ZeOS database access
components and the Indy networking components jump to mind. An increasing number of companies makes its Delphi libraries available for Lazarus and Free Pascal.


Free Pascal is a mature compiler, excellently suitable for any programming
task at hand. FPC shines especially where it concerns cross-platform
applications: the ease with which applications for Windows and Linux can be
developed is simply astonishing. On top of this the Lazarus project offers a
2-way IDE for the development of GUI (Desktop) applications, something
scarcely available for C or C++ under Linux. This domain is traditionally
reserved to interpreted languages such as Java or C#, which suffer from
problems such as excessive memory usage, slow performance and
maintainability. All in all it can be said that the combination FPC/Lazarus
is a good choice for cross-platform development.


  1. 2007-09-10 4:37 pm
    • 2007-09-10 5:16 pm
      • 2007-09-11 7:42 am
      • 2007-09-11 11:26 am
    • 2007-09-10 6:41 pm
      • 2007-09-10 10:18 pm
      • 2007-09-11 11:27 am
    • 2007-09-10 10:10 pm
      • 2007-09-10 10:18 pm
      • 2007-09-11 9:44 am
    • 2007-09-10 10:19 pm
      • 2007-09-10 10:35 pm
        • 2007-09-11 1:25 am
          • 2007-09-11 1:57 am
          • 2007-09-11 8:49 am
          • 2007-09-11 8:09 pm
          • 2007-09-12 8:16 am
          • 2007-09-11 6:16 am
          • 2007-09-11 8:10 pm
        • 2007-09-11 11:28 am
          • 2007-09-11 7:00 pm
    • 2007-09-11 7:46 am
  2. 2007-09-10 5:08 pm
    • 2007-09-11 11:30 am
  3. 2007-09-10 5:48 pm
    • 2007-09-10 5:59 pm
    • 2007-09-10 6:03 pm
  4. 2007-09-10 6:09 pm
  5. 2007-09-10 7:52 pm
    • 2007-09-10 8:01 pm
    • 2007-09-11 11:14 am
      • 2007-09-12 4:42 am
  6. 2007-09-11 12:04 am
    • 2007-09-11 6:07 am
    • 2007-09-11 7:53 am
      • 2007-09-11 8:27 am
        • 2007-09-11 9:59 am
          • 2007-09-11 12:40 pm
          • 2007-09-11 1:12 pm
          • 2007-09-11 2:57 pm
          • 2007-09-11 3:18 pm
          • 2007-09-11 8:55 pm
          • 2007-09-11 6:53 pm
          • 2007-09-11 6:36 pm
          • 2007-09-12 8:12 am
          • 2007-09-12 11:22 am
          • 2007-09-12 2:20 pm
          • 2007-09-12 5:17 pm
          • 2007-09-12 8:39 pm
          • 2007-09-14 4:35 am
  7. 2007-09-11 4:00 am
    • 2007-09-11 4:22 am
    • 2007-09-11 4:27 am
      • 2007-09-11 5:06 am
        • 2007-09-11 12:09 pm
    • 2007-09-11 8:55 am
  8. 2007-09-11 6:28 am
  9. 2007-09-11 7:30 am
    • 2007-09-11 12:11 pm
  10. 2007-09-11 7:34 am
  11. 2007-09-11 8:50 am
  12. 2007-09-12 6:31 pm
  13. 2007-09-15 12:57 am