Search code examples
lazarusdelphi

Opening lazarus project on a new PC


When I open an existing Lazarus IDE project on a new computer it does not want to compile. A window with this code pops up in the source editor

program C05e01p;

{$mode objfpc}{$H+}

uses
  {$IFDEF UNIX}{$IFDEF UseCThreads}
  cthreads,
  {$ENDIF}{$ENDIF}
  Interfaces, // this includes the LCL widgetset
  Forms, C05e01u, LResources
  { you can add units after this };

{$IFDEF WINDOWS}{$R C05e01p.rc}{$ENDIF}

begin
  {$I C05e01p.lrs}
  Application.Initialize;
  Application.CreateForm(TfrmBoolean, frmBoolean);
  Application.Run;
end.

And the error is:

C05e01p.lpr(20,1) Error: resource compiler "windres.exe" not found, switching to external mode


Solution

  • I've run into this before. Generally it is from an incorrect installation of Lazarus. A 64 bit version of Lazarus trying to use a 32 bit windres, or vice versa.

    If you are installing on a 64 bit computer and want the ability to compile both 32 and 64 bit targets, then you have to install a 32 bit native version of Lazarus as the primary install, then add 64 bit cross compilation. Failure to do this will lead to problems like you've run into. Unfortunately there is no official packaging of Lazarus that Just Works™ out of the box with both 32 and 64 bit targets and the requirements for getting it to work right are very poorly documented within the project. To make matters worse, there are many different flavours and "distributions" (akin to Linux distributions) of Lazarus available now and the community is somewhat fragmented among them.

    There, however, is a Lazarus installer project called fpcupdeluxe that can be used to put together a good installation. You will want to download the -386-win32 version of this tool and use it to install a base version. This tool can be used to install many of the different flavours out there, I recommend starting out to go with the "stable" button at the bottom which will select the latest stable release version of FPC and Lazarus. This will give you a working 32 bit version of FPC/Lazarus. You can then use the same tool and select the x86_64/Windows cross compiler and install that.

    The tool is very powerful, it can be used to install many common component packages as well. Keep in mind that both fpcupdeluxe and many of the component packages it can install are under heavy development. There is a support thread for fpcupdeluxe on the Lazarus forums. I recommend before deciding to use the tool to get any particular component package to always update to the latest version.