Chapter 1a: Compilation and configuration of Lazarus

Before you start following the instructions given here to install Lazarus make sure you really need it. The Lazarus package is completly independent of SDL. If you are not interested in a DELPHI-like RAD (Rapid Application Development) tool skip this chapter. You could come back later after you finished all SDL chapters :). This chapter isn't required to do the following chapters.

Otherwise the combination of Freepascal together with the SDL Library and Lazarus' abilities can lead to a very flexible and highly powerful development environment. The advantages of Freepascal, like OS independence, open source code, a license which allows you to develop commercial programs (license: LGPL), and so on apply for Lazarus, too! Furthermore you gain all advantages modern OS and IDE provide. The DOS-like IDE of the Freepascal compiler is legendary but nowadays not too comfortable anymore. The Lazarus environment provides a flexible and comfortable IDE.

The following description on how to compile/install and configure Lazarus is for WINDOWS ONLY. I am sorry that I am currently not able to make such a description to linux users. Any reader is welcome to send me one, so I could publish it here (you would get full credit of course). Futhermore it is necessary that you have completed Chapter 1

The following table describes what software you will need additionally to the Freepascal compiler:

SoftwareVersionSize, MBSourceDescription
Lazarus source filesLatest revisiondependsdirectly through SVNHow to get them will be described next!
TortoiseSVN1.4.7~2http://tortoisesvn.net/Download the latest version of SVN client (except you already have such a client).
fpcbuild-2.2.0.zip2.2.0~38http://www.freepascal.orgDownload the latest source files of the Freepascal compiler. Go to "Download" and scroll down to "Source".

Now let's begin. First of all I want you to know that there are some binaries downloadable from the official Lazarus page. These binaries shouldn't be used because they are very old and the resulting Lazarus environment is terribly unstable! The environment is much more improved and gets improved daily. So I advise you to get the latest development state through SVN (it's like the outdated CVS). If you neither know SVN nor CVS here a short description: SVN provides the latest state of development and ensures that any of several hundreds developers of a project (like Lazarus) is working on the latest version. Whenever a developer is changing anything at the project SVN generates a new revision number. Today the revision number of Lazarus is 13688.

How to get the latest development state (revision) of lazarus then? - That is described very clearly and easy here: http://wiki.lazarus.freepascal.org/index.php/Getting_Lazarus. Therefore I will just describe short how to get it.

1) get the mentioned SVN client (TortoiseSVN) for Windows and install it
2) create a directory where you want to have Lazarus installed later (e.g. C:\FPC\Lazarus)
3) right-click on the new created lazarus folder and chose "SVN Checkout..."; you get the following window



4) type in field URL of repository: "http://svn.freepascal.org/svn/lazarus/trunk" (without quotationmarks) as shown in the picture above; if you use a command line client (e.g. Subversion you have to type "svn co http://svn.freepascal.org/svn/lazarus/trunk lazarus" (without quotationmarks))
5) click "OK"
6) another window pops up called "trunk - SVN Checkout..."; now it will take some minutes; after all files got downloaded you receive a window similar to this:



(you can go on reading while waiting)


The files you download through SVN aren't binaries. That means you have to compile them. The compiler you use to do so is the Freepascal compiler of course (that is why you should have it installed already).

7) If the downloading is finished you have to go to the folder where all the files are placed, e.g. C:\FPC\lazarus\.
8) Now you have to run a command line tool like "cmd". Choose "Start" and then "Run..." from Windows' start menu.
9) Enter "cmd" or "command.com" (latter only if "cmd" doesn't work) in the next pop-up window and click "OK". Now a window like this should pop up:



10) Go to the directory where you downloaded the Lazarus files. (Use the DOS commands "cd [directory]" and "cd.." to enter or leave directory.)
11) When you entered the directory (C:\FPC\lazarus\) just type "make" and the make.exe of your Freepascal compiler will compile Lazarus for you. Now relax and wait some minutes.

If this doesn't work for you, you should try to copy the make.exe from your Freepascal compiler (located in bin directory) to the Lazarus directory (or you could check if you set the environment variable/user variable PATH=C:\FPC\2.2.0\bin\i386-win32 in system control)
12) After successful compilation there should be a Lazarus.exe and a Startlazarus.exe right in the lazarus directory. Use Startlazarus.exe to run your brand new RAD tool :). After passing some error messeges you should get something similar to this:


(Click to enlarge)

13) close Lazarus


The next steps describe how to configure Lazarus together with JEDI-SDL. This includes telling Lazarus where to find Freepascal compiler, where to find Freepascal source files and where to find JEDI-SDL units. ATTENTION: It is necessary to have the source files of Freepascal, otherwise Lazarus won't run properly. If you installed Freepascal and JEDI-SDL as described in Chapter 1 you don't have the source files because they are not included in the binary package. Fortunately this doesn't matter because you can download them separately. If you already have the source files for some reason you can skip step 14 and 15.

14) Download the latest source files of the Freepascal compiler (usually it doesn't matter if the version of the source files differ slightly from the version of actual compiler).
15) Now extract the file. It doesn't matter where the source files are located but you may prefer a folder like "C:\FPC\2.2.0\source\".
16) The extraction generates a folder "fpcbuild-2.2.0". The whole path should be "C:\FPC\2.2.0\source\fpcbuild-2.2.0\".
17) Now run Lazarus and skip any error message. Go to "Environment" in the menu.



Choose "Environment options" from the tab. The following window should come up.



18) The text field "Lazarus directory (default for all projects)" should be filled with your Lazarus path, if not do so. The text field "Compiler path (ppc386.exe)" should be filled with your Freepascal compiler path, if not do so.
19) The text field "FPC source directory" is probably empty. The sources are needed for Lazarus to compile projects successfully. Fill in the path where you extracted the source files in step 15. If you followed my suggestion the correct path would be "C:\FPC\2.2.0\source\fpcbuild-2.2.0\fpcsrc\". Confirm by clicking "OK".
20) If you haven't done any mistakes there shouldn't be any error anymore if you close and restart Lazarus.
21) Now let's tell Lazarus where to find the JEDI-SDL units. Go to "Project" in menu.



Choose "Compiler Options..." from the tab. The following window should come up but without any entry in the text field "Other Unit Files (-Fu) (Delimiter is semicolon);".



22) Enter the path to the JEDI-SDL units. If you installed JEDI-SDL as mentioned in Chapter 1 you should enter "C:\FPC\2.2.0\units\JEDI\SDL\Pas". Now you are ready to write Freepascal programs in Lazarus using JEDI-SDL. Note: The environment settings are saved for any project but the compiler settings (steps 20-22) are just related to the current project so you have to set the unit path to JEDI-SDL units separate for each project.


Now you have a brand new RAD tool installed. Well done! This tool you can use to write just plain Freepascal or/and Freepascal/SDL programs. You also can combine these programs with the features typical RAD kits provide but to learn how to use those features is described anywhere else. Have fun.



M. Molski
















to mainpage



Creation/Updates: 13/4/2009; 11/1/2008
There is no guarantee that things will work! You do everything described here on your own risk! © M. Molski 2005-2009. All product and company names, brand names, trademarks and logos are the property of their respective owners.