Lazarus Faq/de

From Lazarus wiki
Revision as of 19:07, 23 August 2005 by Swen (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigationJump to search

Allgemein

Where can I find more FAQ?

See the official website www.lazarus.freepascal.org. There is another FAQ as well.

Do I need ppc386.cfg or fpc.cfg?

You only need fpc.cfg. This way the compiler knows where to find the libraries.

How do I compile lazarus?

Do something like this:

$ cd lazarus
$ make

How do I build other projects based upon the LCL

Add the following lines to the end of your fpc.cfg

  1. Add Lazarus libs
 -Fu/your.lazarus.root/lcl/units
 -Fu/your.lazarus.root/lcl/units/{YourToolKit}
 -Fu/your.lazarus.root/components/units
 -Fu/your.lazarus.root/components/units/{YourToolKit}
Where {YourToolKit} may be GTK, Gnome or Win32 and run:
ppc386 your.project.pp

What version of FPC is required?

Currently you need to use 1.0.10 of the FPC compiler. You can find the URL in the downloads section of this site. FPC Version 2.0.0 has been released, and you are strongly recommended to use this latest stable version.

I can't compile Lazarus

  1. Check if the compiler has the correct version
  2. Check if the (fpc)libraries are from the same version.
  3. Check if you have a fpc.cfg and no old ppc386.cfg
  4. Check also the OS-dependent FAQs

When I try to compile a project, I have an error

"Cannot find Unit interfaces". How can I solve this?

This compiled unit can be found in {LazarusDir}\lcl\units\{TargetCPU}\{TargetOS}\{LCLWidgetSet}\interfaces.ppu.

If you selected a different widgetset than you used to build lazarus, you need to build the LCL for this widgetset.

If it is there, but you get this error, you are using a different compiler / rtl for compiling your project than you used for compiling your Lazarus IDE. You can do one of the following

  • Rebuild the LCL (or Lazarus completely) with the compiler selected in the Environmnent Options. You can this with Tools -> Build Lazarus. Before doing this, check the current settings in Tools -> Configure Build Lazarus.
  • Change the compiler in the Environment Options to the one you used to compile Lazarus. Look carefully also in the Environment Options to see if you are using the correct paths for the Lazarus Directory and the FPC sources directory. Check that there is only one version of the compiler configuration file fpc.cfg - it should reside in /etc/ for Linux/Unix systems or in the same directory as the fpc compiler for Windows systems. Rogue copies often creep in if you have updated your compiler to a new version; they may be found in your home directory or in the same directory as the one in which you built your new compiler. DELETE THESE!!

When I try to compile delphi projects under lazarus, I have an error

at the line :{$R *.DFM} How can I solve this problem ?

Lazarus (or better Linux) doesn't know about resources, so you can't use them in the way Delphi/win32 does. However Lazarus uses a method pretty compatible with this. You can still use your Delphi layouts (.dfm files) if you use the following steps:

  • You need a textual version of the .dfm files. D5 and higher are doing this as default. If you have older files: ALT-F12 to see the layout as text and paste/copy. When you have a text .dfm file, just copy it to a .lfm file.
  • Create a file with lazres (in lazarus/tools) lazres yourform.lrs yourform.lfm
  • Add the following initialization section to
     initialization
     {$I yourform.lrs}

Please keep in mind that not all properties in the dfm are supported yet by lazarus, so you might get a crash.

'Identifier not found LazarusResources'.

When creating a form Lazarus automaticaly add some extra units to the uses section of your form unit. During the conversion of a delphi unit to a Lazarus unit this does not happen. So you need to add LResources to the Uses section of your form unit.

When accessing events of objects e.g. the onclick event of a button I get the following error. ERROR unit not found: stdCtrls

Make sure, in the Project -> Project Inspector, that your project depends on the package 'LCL' and that you have installed the FPC sources.

Lazarus is the IDE and the visual components library LCL. All other stuff, like IO, Database, FCL and RTL are provided by FPC. The IDE needs the paths to all sources.

The FPC source path can be set via: Environment -> General Options -> Files -> FPC source path

How to embed a small file in the executable, without the need of a separate file? How to embed a resource?

For example:

/your/lazarus/path/tools/lazres sound.lrs sound1.wav sound2.wav ...

will create sound.lrs from sound1.wav and sound2.wav.

Then include it *behind* the form lrs file:

...
initialization
{$i unit1.lrs} // this is main resource file (first)
{$i sound.lrs} // user defined resource file

end.

In your program you can then use:

Sound1AsString:=LazarusResources.Find('sound1').Value;

How can I see debug output?

The LCL has in the LCLProc procedure to write debug output:

  • DebugLn: works about the same as WriteLn, but accepts only strings.
  • DbgOut: works about the same as Write, but accepts only strings.

In normal circumstances the output is written to stdout. If stdout is closed, (for example when the application is {$AppType Gui} or compiled with -WG on windows), no output is written.

Debug output can also be written to file. The LCLProc unit checks in its initialization the command line parameters for '--debug-log=<file>'. If it finds it sends debug output to <file>.

If it doesn't find a --debug-log command line parameter, it looks if an environment variable xxx_debuglog exists, where xxx is the program file name without extension. For lazarus this would be lazarus_debuglog. If such an environment variable exists, it uses that as file to write debug output to. Example: if you do:

set lazarus_debuglog=c:\lazarus\debug.txt

debug output will be written to c:\lazarus\debug.txt.

Since this is implemented in lclproc, every application using lclproc, can use this output facility.

Debuging Lazarus
Most usefull for windows: If you want output on a console, add {$APPTYPE console} to lazarus.pp ; Then rebuild Lazarus.