[Lazarus] Compiling LCL units via commandline

Mattias Gaertner nc-gaertnma at netcologne.de
Wed Jul 25 15:51:24 CEST 2012


On Wed, 25 Jul 2012 08:01:50 -0300
luciano de souza <luchyanus at gmail.com> wrote:

> Hello listers,
> 
> I am blind and I use Freepascal by means of a screen reader. Recently,
> I and other four blind programers wanted to compile a project which
> implies the usage of LCL units. The very reduced accessiblity of
> Lazarus environment make us to decide to compile everything via FPC.
> 
> fpc project.pp
> 
> Under FPC, it doesn't compile. In spite of the fact FPC is inside the
> Lazarus, it does not configured to search for LCL units.

The LCL and many other packages require some flags depending on the
target platform and build mode. These flags are probably not needed nor
wanted by your units. fpc allows to compile different units with
different flags.
That's why the LCL is compiled with one call of fpc, which creates a
bunch of files for each unit. For example the ppu and o files. They
are put into a separate directory, which is called the "output
directory" of the package.
Only the output directories of the packages must be added to the search
path, not the sources itself. If you add the source directories the
compiler may compile the units again, but this time with the wrong
flags. Never do that.

Lazarus stores these flags in the lpi and lpk files and
automatically compiles the units as needed and in the right order. It
checks for consistency too. The IDE has filters to show only the
important messages and improves some compiler messages, for example
"can not find unit".

lazbuild is a command line tool to compile Lazarus projects and
packages. It lacks the ability to filter messages. It simply prints all
output of fpc.


> So we add in
> fpc.cfg:
> 
> -FuC:\lazarus\components
> -FuC:\lazarus\components\*
> -FUC:\lazarus\lcl
> -FUC:\lazarus\lcl\*
> -FiC:\lazarus\lcl\include
> -FuC:\lazarus\units
> -FuC:\lazarus\units\*
> 
> The paths were found, but there is a circular reference between
> messages and lmessages.
> 
> Having reported it in a forum, I member told me about lazbuild. I
> should manually create a XML file with the project settings and try to
> compile again. The same error about circular reference is raised.
> 
> Yes, Lazbuild can be used. But I confess this option strongliy upset
> me. Lazbuild calls several routines and after all calls FPC. If you
> imagine the screen reader reads all the output, not having a way to
> jump the unneeded information, you will evaluate how slow can be the
> compilation using Lazbuild. The output of FPC is not so verbose, so
> it's prefferable to use FPC without Lazbuild.
> 
> I tried to compile the following example program:
> 
> program e026;
> {$mode objfpc}{$H+}
> 
> uses
> interfaces, dialogs;
> 
> BEGIN
> END.
> 
> Under certain point of view, our project has an educational focus.
> Blind programers with few or any experience is our public. If the
> first contact with Pascal is complex, people can give up. And the
> first contact, according this project, implies the usage of LCL. There
> is a Pascal voice system called Dosvox writen in Pascal. It offers a
> good set of units for developers. Let me give you an example: the crt
> unit was converted into dvcrt unit and syntwriteln in place of only
> show a message, can also speak it.
> 
> My conclusion is: I need LCL, but how to compile any code using only
> Freepascal? How can I configure my fpc.cfg to search for any unit in
> Lazarus folders and compile any type of project? Console? Graphical?

If you want to compile any type of project, then you must use lazbuild
or the IDE, because some projects need more than a call to fpc.

If you want to compile simple projects, then you can compile a project
once. This creates a file projectname.compiled. It contains the command
line parameters needed by fpc to compile your project, so you can paste
that into whatever IDE you prefer and adjust the verbosity flags of the
compiler to your needs.

 
> And to avoid this work, I suggest the standard distribution of Lazarus
> includes an FPC configured to compile everything.
> The ideal would be to do all in the Lazarus interface, but it's
> impossible. Among other reasons, the label of widgets produced by LCL
> can't be read by screen readers. But it's subject for another message!

Mattias




More information about the Lazarus mailing list