[Lazarus] Where to define conditionals for FPC

Juha Manninen juha.manninen62 at gmail.com
Mon May 11 11:06:33 CEST 2020

On Fri, May 8, 2020 at 7:03 PM Bo Berglund via lazarus
<lazarus at lists.lazarus-ide.org> wrote:
> All of this works OK in Delphi 2007 when I use the GUI to set the
> conditional variables.

You must have separate projects for Delphi and Lazarus in any case.
Maintaining those variables in the Delphi project should not be a problem.

> But what is worrying me is that the Lazarus Delphi Converter will not
> find these conditionals and then convert stuff that are to be Delphi
> only...
> As far as I have understood the converter does not read the dproj file
> where Delphi stores these settings.
> But I might be overly anxious? Maybe Lazarus Delphi Converter can read
> the dproj file and find the settings?

No, a .dproj file is not supported currently.
The converter reads .dpr project file and also .dof and .cfg files if
available. At least earlier Delphi versions stored settings in those.

> I made a test conversion a number of weeks ago and it failed because
> of a lot of dependencies on components with no FCP counterpart etc...
> Then I had to backtrack a lot to get the project in working order
> again and decided to try to make the code FPC aware via the
> conditionals and still keep the way it works now.

Some projects are almost impossible to convert because they have
components which are not ported to Lazarus.
The automatic conversion cannot help you there.

On Mon, May 11, 2020 at 10:33 AM Bo Berglund via lazarus
<lazarus at lists.lazarus-ide.org> wrote:
> 2) Lazarus project file (lpi)
> When you convert to Lazarus are you also getting an lpi file?

Yes. When a project is converted for Lazarus you obviously get an .lpi
project file.

> And does the lpi file contain references into the Delphi install
> directories?
> The lpi file from my first (failed) conversion contains stuff like
> this:
>     <SearchPaths>
>       <IncludeFiles Value="C:\Programs\CodeGear\RAD
> Studio\5.0\source\Win32\vcl\;..\..\..\CMP\SentinelAGI;..\..\..\CMP\Log3R;..\..\..\CMP\SystemResource;..\..\..\CMP\Version;..\..\Common;..\..\..\CMP\AsyncPro\source;..\..\..\CMP\DLPortIO\source;..\..\..\CMP\Indy10\Protocols;$(ProjOutDir)"/>
>       <OtherUnitFiles Value="C:\Programs\CodeGear\RAD
> Studio\5.0\source\Win32\vcl\;..\..\..\CMP\SentinelAGI;..\..\..\CMP\Log3R;..\..\..\CMP\SystemResource;..\..\..\CMP\Version;..\..\Common;..\..\..\CMP\AsyncPro\source;..\..\..\CMP\DLPortIO\source;..\..\..\CMP\Indy10\Protocols;C:\Programs\CodeGear\RAD
> Studio\5.0\source\Win32\rtl\win\"/>
>       <UnitOutputDirectory Value="..\bin"/>
>     </SearchPaths>

It means those directories are in your Delphi project settings. Why
are they there? Usually Delphi stores them in a global search path
when components are installed.
If they are also in the global search path, they can be removed from
the project and the converter will not add them.

> 3) Compiling same code with Delphi and FPC?
> Do you convert your projects (manually) to make it possible to use
> both Delphi and Lazarus as the IDE for further work on the same
> sources?
> If so do you have any hints as to what to look out for?

Experience has proven that maintaining a project for both Delphi and
Lazarus is difficult. At some point you will decide to dump the Delphi
Maybe you should rethink your porting strategy and do a one-direction
conversion from the beginning. You would save time in the long run.
During a transition period you must maintain 2 versions, one for
Delphi and one for Lazarus, but you don't need to struggle with an
IFDEF mess.
Replacing code and the whole porting process becomes easier.


More information about the lazarus mailing list