Difference between revisions of "Lazarus Faq/de"

From Lazarus wiki
Jump to navigationJump to search
Line 68: Line 68:
 
Wenn ein Formular erzeugt wird, dann fügt Lazarus automatisch einige zusätzliche Units zu dem uses Abschnitt ihrer Formular-Unit hinzu. Während der Konvertierung von einer Delphi Unit zu einer Lazarus Unit passiert dies nicht. Daher müssen sie LResources zu dem uses Abschnitt ihrer Formular-Unit (manuell) hinzufügen.
 
Wenn ein Formular erzeugt wird, dann fügt Lazarus automatisch einige zusätzliche Units zu dem uses Abschnitt ihrer Formular-Unit hinzu. Während der Konvertierung von einer Delphi Unit zu einer Lazarus Unit passiert dies nicht. Daher müssen sie LResources zu dem uses Abschnitt ihrer Formular-Unit (manuell) hinzufügen.
  
=== When accessing events of objects e.g. the onclick event of a button I get the following error. ERROR unit not found: stdCtrls ===
+
=== Wenn Ereignisse von Objekten angesteuert werden z.B. das OnClick Ereignis einer Schaltfläche, erhalte ich die folgende Fehlermeldung: 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.
+
Stellen sie sicher, unter Projekt -> Projektinspektor, daß ihr Projekt auf dem Package 'LCL' beruht und daß sie die FPC Quellen installiert haben.
  
Lazarus is the IDE and the visual components library LCL.
+
Lazarus ist die IDE und die visuelle Komponenten Bibliothek LCL.
All other stuff, like IO, Database, FCL and RTL are provided by FPC.
+
Alle anderen Dinge, wie IO, Datenbanken, FCL und RTL werden von FPC zur Verfügung gestellt.
The IDE needs the paths to all sources.
+
Die IDE benötigt die Pfade zu allen Quellen.
  
The FPC source path can be set via:
+
Der FPC Quellen Pfad kann gesetzt werden via:
Environment -> General Options -> Files -> FPC source path
+
Einstellungen -> Umgebungseinstellungen -> Dateien -> FPC-Quelltextverzeichnis
  
 
===Wie kann man eine kleine Datei in das ausführbare Programm einbetten, ohne eine separate Datei zu benötigen? Wie kann man eine Ressource einbetten?===
 
===Wie kann man eine kleine Datei in das ausführbare Programm einbetten, ohne eine separate Datei zu benötigen? Wie kann man eine Ressource einbetten?===

Revision as of 17:57, 5 October 2005

Allgemein

Wo kann ich weitere FAQs finden?

Besuchen Sie die offizielle Webseite www.lazarus.freepascal.org . Dort gibt es eine weitere FAQ.

Brauche ich ppc386.cfg oder fpc.cfg?

Sie brauchen nur fpc.cfg. Auf diese Weise kann der Compiler die Bibliotheken finden.

Wie kompiliere ich Lazarus?

Do something like this:

$ cd lazarus
$ make

Wie erzeuge ich andere Projekte basierend auf der LCL?

Fügen Sie die folgenden Zeilen am Ende ihrer fpc.cfg ein

  1. Hinzufügen der Lazarus Bibliotheken
 -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}
  1. Wenn ihr Toolkit GTK, Gnome oder Win32 ist starten Sie:
ppc386 your.project.pp

Welche Version von FPC wird benötigt?

Da inzwischen die FPC Version 2.0.0 erschienen ist, sollten ältere Versionen (1.x.x) nicht mehr verwendet werden. Die URL ist im Downloadbereich dieser Version zu finden.

Ich kann Lazarus nicht kompilieren.

  1. Prüfen Sie, ob der Compiler die richtige Version hat.
  2. Prüfen Sie, ob die (fpc) Bibliotheken (libraries) dieselbe Version haben.
  3. Prüfen Sie, ob Sie die fpc.cfg haben und nicht die alte ppc386.cfg.
  4. Prüfen Sie auch die betriebssystemabhängigen FAQs.

Wenn ich versuche, ein Projekt zu kompilieren, bekomme ich eine Fehlermeldung:

"Kann Unit interfaces nicht finden". Wie kann ich das Problem lösen?

Die kompilierte Unit ist zu finden in {LazarusDir}\lcl\units\{TargetCPU}\{TargetOS}\{LCLWidgetSet}\interfaces.ppu.

Wenn sie ein anderes Widgetset ausgewählt haben, dann müssen sie die LCL für dieses Widgetset erzeugen, um Lazarus zu erzeugen.

Wenn es dort ist, sie aber diese Fehlermeldung erhalten, dann benutzen sie einen anderen Compiler / rtl für die Kompilierung ihres Projekts als sie für die Kompilierung ihrer Lazarus IDE benutzt haben. Sie können eine der folgenden Maßnahmen ergreifen:

  • Bauen sie die LCL neu auf (rebuild)(oder Lazarus komplett) mit dem Compiler, der in den Umgebungsoptionen selektiert ist. Sie können dies tun mit Werkzeuge -> Lazarus erstellen. Bevor sie dies tun, prüfen sie die gegenwärtigen Einstellungen in Werkzeuge -> Konfigurieren von Lazarus erstellen.
  • Ändern sie den Compiler in den Umgebungsoptionen auf denjenigen, den sie zum kompilieren von Lazarus benutzt haben. Schauen sie auch sorgfältig in den Umgebungsoptionen nach, ob sie die richtigen Pfade für das Lazarus Verzeichnis und das FPC Quellverzeichnis benutzen. Prüfen sie, daß es nur eine Version der Compiler Konfigurationsdatei fpc.cfg gibt - sie sollte sich befinden in /etc/ für Linux/Unix Systeme oder in dem selben Verzeichnis wie der fpc Compiler für Windows Systeme. Rogue Kopien schleichen sich oft ein wenn sie ihren Compiler auf ein neuere Version upgedated haben; sie können gefunden werden in ihrem home Verzeichnis oder in den dem selben Verzeichnis , in dem sie ihren neuen Compiler erstellt haben. Löschen sie diese!!

Wenn ich versuche, Delphi Projekte unter Lazarus zu kompilieren, erhalte ich eine Fehlermeldung

auf der Zeile :{$R *.DFM} Wie kann ich das Problem lösen ?

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'.

Wenn ein Formular erzeugt wird, dann fügt Lazarus automatisch einige zusätzliche Units zu dem uses Abschnitt ihrer Formular-Unit hinzu. Während der Konvertierung von einer Delphi Unit zu einer Lazarus Unit passiert dies nicht. Daher müssen sie LResources zu dem uses Abschnitt ihrer Formular-Unit (manuell) hinzufügen.

Wenn Ereignisse von Objekten angesteuert werden z.B. das OnClick Ereignis einer Schaltfläche, erhalte ich die folgende Fehlermeldung: ERROR unit not found: stdCtrls

Stellen sie sicher, unter Projekt -> Projektinspektor, daß ihr Projekt auf dem Package 'LCL' beruht und daß sie die FPC Quellen installiert haben.

Lazarus ist die IDE und die visuelle Komponenten Bibliothek LCL. Alle anderen Dinge, wie IO, Datenbanken, FCL und RTL werden von FPC zur Verfügung gestellt. Die IDE benötigt die Pfade zu allen Quellen.

Der FPC Quellen Pfad kann gesetzt werden via: Einstellungen -> Umgebungseinstellungen -> Dateien -> FPC-Quelltextverzeichnis

Wie kann man eine kleine Datei in das ausführbare Programm einbetten, ohne eine separate Datei zu benötigen? Wie kann man eine Ressource einbetten?

Zum Beispiel:

/ihr/Lazarus/Pfad/tools/lazres sound.lrs sound1.wav sound2.wav ...

wird sound.lrs aus sound1.wav und sound2.wav erzeugen.

Dann fügen sie es hinter der Formular lrs Datei ein:

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

end.

In ihrem Programm können sie dann verwenden:

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

Wie kann ich den debug output sehen?

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.

Nutzung der IDE

Wie kann ich die "identifier completion" nutzen?

Sie können die "identifier completion" aufrufen, indem Sie die Tasten [Ctrl][Leertaste] drücken. Unter dem Menüpunkt Environment -> Editor Options -> Code Tools -> Automatic Features können Sie einstellen, wie schnell dies automatisch passieren soll.

Linux

Wie kann ich unter Linux ohne die IDE debuggen?

Zuerst benötigen sie einen Debugger. gdb ist der Standard Debugger unter Linux und verschiedene GUI-frontends sind verfügbar. Ein gebräuchliches Frontend ist ddd, welches ein Teil der meisten gebräuchlichen Distributionen ist. Um Lazarus/lcl mit Debug Informationen zu kompilieren, sollten sie die folgenden Kommandos benutzen, um eine Debug Sitzung zu starten:

 $ make clean; make OPT=-dDEBUG
 $ ddd lazarus

Seien sie jedoch gewarnt, daß ddd nicht so komfortabel wie z.B. der Lazarus Debugger ist. Specially if it comes to view the contents of a variable you have to take into account that ddd/gdb are case sensitive whereas Pascal is case-insensitive. Therefore you have to type all variable names in uppercase to see their contents. For more information take a look into the fpc-manuals.

Ich kann jetzt debuggen, aber ddd findet meine Quellen nicht oder reklamiert, daß sie keinen Code enthalten. Was ist das?

This is a path-related problem with either gdb or ddd. You can aviod this by

  • Use the "Change directory" command from the ddd menu and choose the directory where the sources are located. The drawback of this method is that you now can't use the source of the program you started with (e.g. lazarus). Thus it may be neccessary to change the directory multiple times.
  • In ddd goto [Edit] [gdb-settings] and set the search-path
  • Create a $(HOME)/.gdbinit file like:
     directory /your/path/to/lazarus
     directory /your/path/to/lazarus/lcl
     directory /your/path/to/lazarus/lcl/include

I receive an error during the linking that states /usr/bin/ld can't find -l<some lib>

Package Based Distributions
You need to install the package that provides the lib<somelib>.so or lib<somelib>.a files. Dynamic libs under linux have the extension .so, while static libs have the extension .a. On some Linux distro's you have installed the package (rpm, deb) <packagename> which provides <some lib>, but you also need the development package (rpm, deb), normally called <packagename>-dev, which contains the .a (static lib) and/or the .so (dynamic lib).
Source Based Distributions and Manual Compilation (LFS)
Make sure that there is a lib<somelib>.a in the path, and that it contains the right version. To let the linker find the dynamic library, create a symlink called lib<some lib>.so to lib<some lib><version>-x,y.so if necessary (and/or for static lib; lib<some lib>.a to lib<some lib><version>-x,y.a).
FreeBSD
As source based distro's, and also make sure you have -Fl/usr/local/lib in your fpc.cfg and/or Lazarus library path. Keep in mind that GTK1.2 has "gtk12" as package name under FreeBSD. (same for glib)
NetBSD
As source based distro's, and also make sure you have -Fl/usr/pkg/lib in your fpc.cfg and/or Lazarus library path

Wie kann ich ein Kylix 2 Projekt in ein Lazarus Projekt konvertieren?

Beinahe auf die selbe Weise wie man ein Kylix Projekt in ein Delphi/VCL Projekt konvertiert.

Die LCL (Lazarus Component Library) versucht kompatibel zu Delphis VCL zu sein. Kylix CLX versucht kompatibel zu QT sein. Hier sind einige allgemeine Hinweise:

  • Benennen sie alle benutzten CLX Q-Units wie QForms, QControls, QGraphics, ... in ihre VCL Entsprechungen: Forms, Controls, Graphics, ... um.
  • Fügen sie LResources zum uses Abschnitt jeder Formualer Quelle hinzu.
  • Benennen sie alle .xfm Dateien in .lfm Dateien um oder kopieren sie sie.
  • Benennen sie die .dpr Dateien in .lpr Dateien um oder kopieren sie sie.
  • Entfernen sie die {$R *.res} Direktive.
  • Entfernen sie die {$R *.xfm} Direktive.
  • Fügen sie die {$mode objfpc}{$H+} oder {$mode delphi}{$H+} Direktive zu den .pas und .lpr Dateien hinzu.
  • Fügen sie einen initialization Abschnitt am Ende jeder Formularquelle hinzu und auch eine include Direktive für die .lrs Datei (lazarus resource file):
 initialization
   {$I unit1.lrs}
Die .lrs Dateien können erzeugt werden mit dem lazres Tool in: (lazarusdir)/tools/lazres.
Zum Beispiel: ./lazres unit1.lrs unit1.lfm
  • Fix the differences. Die LCL unterstützt noch nicht jede Eigenschaft der VCL und die CLX ist nicht völlig VCL kompatibel.

Während der Kompilierung von Lazarus kann der Compiler eine Unit nicht finden. (z.B. gtkint.pp(17,16) Fatal: Can't find unit GLIB)

1. Check a clean rebuild: do a 'make clean all'

2. Check if the compiler has the correct version (1.0.10 or 1.1)

3. Check if the compiler is using the right config file. The normal installation creates /etc/fpc.cfg. But fpc also searches for ~/.ppc386.cfg, ~/.fpc.cfg, /etc/ppc386.cfg and it uses only the first it finds.

Hint: You can see which config file is used with 'ppc386 -vt bogus'

4. Check if the config file (/etc/fpc.cfg) contains the right paths to your fpc libs. There must be three lines like this:

   -Fu/usr/lib/fpc/$version/units/$target
   -Fu/usr/lib/fpc/$version/units/$target/*
   -Fu/usr/lib/fpc/$version/units/$target/rtl
The first part of these paths (/usr/lib/fpc) depends on your system. On some systems this can be for example /usr/local/lib/fpc/... .
Hint: You can see your searchpaths with 'ppc386 -vt bogus'

5. Check that the config file (/etc/fpc.cfg) does not contain search paths to the lcl source files (.pp, .pas):

 forbidden: -Fu(lazarus_source_directory)/lcl
 forbidden: -Fu(lazarus_source_directory)/lcl/interfaces/gtk
If you want to add the lcl for all your fpc projects, make sure that the two paths look like the following and are placed after the above fpc lib paths:
 -Fu(lazarus_source_directory)/lcl/units
 -Fu(lazarus_source_directory)/lcl/units/gtk

6. Check if the missing unit (glib.ppu) exists in your fpc lib directory. For example the gtk.ppu can be found in /usr/lib/fpc/$version/units/linux/gtk/. If it does not exists, the fpc lib is corrupt and should be reinstalled.

7. Check if the sources are in a NFS mounted directory. In some cases the NFS updates created files incorrectly. Plz try move the sources into a non NFS directory and compile there.

Ich habe die binäre Version installiert, aber wenn ein einfaches Projekt kompiliert wird, meldet Lazarus: Fatal: Can't find unit CONTROLS

Probably you are using a newer fpc package, than that used for building the lazarus binaries. The best solution is to download the sources and compile lazarus manually. You can download the source snapshot or get the source via cvs:

 $ bash
 $ export CVSROOT=:pserver:cvs@cvs.freepascal.org:/FPC/CVS
 $ cvs login
 Hint: The password is cvs (lowercase).
 $ cvs -z3 checkout lazarus
 $ cd lazarus
 $ make

Make sure that lazarus get the new source directory: Environment->General Options->Files->Lazarus Directory Top

Lazarus compiles, but linking fails with: libgdk-pixbuf not found Either install the gdk-pixbuf library for gtk1.x or disable the use:

Where to find the gdk-pixbuf library:

RPMs: http://rpmfind.net/linux/rpm2html/search.php?query=gdk-pixbuf&submit=Search+...&system=&arch=

Debian packages: libgdk-pixbuf-dev

Sources: ftp://ftp.gnome.org/pub/gnome/unstable/sources/gdk-pixbuf/


How to disable the use in lazarus: In Tools->Configure "Build Lazarus" add the option '-dNoGdkPixBufLib' or at command line: "make clean all OPT=-dNoGdkPixBufLib".

I have SuSE and I get /usr/bin/ld: cannot find -lgtk Error: Error while linking

SuSE installs the gtk devel libs under /opt/gnome/lib, which is not in the standard lib path. Simply add it to your /etc/fpc.cfg. (-Fl/opt/gnome/lib).

Windows

When I cycle the compiler, I get:The name specified is not recognized as an internal or external command, operable program or batch file.>& was unexpected at this time.

In the compiler dir exists an OS2 scriptfile named make.cmd. NT sees this also as a script file, so remove it since on NT we don't need it.

When I cycle the compiler, I get: make[3]: ./ppc1.exe: Command not found

I don't know why but somehow make has lost its path. Try to cycle with a basedir set like: make cycle BASEDIR=your_fpc_source_dir_herecompiler

Wenn ich versuche, Lazarus zu erstellen (make), erhalte ich:

make.exe: * * * interfaces: No such file or directory (ENOENT). Stop.make.exe: * * * [interfaces_all] Error 2

Sie müssen ihre make Datei upgraden.

makefile:27: *** You need the GNU utils package to use this Makefile. Stop.

Make sure you didn't install FPC in a path with spaces in the name. The Makefile doesn't support it.

Wenn ich versuche, bei CVS einzuloggen, erhalte ich die Meldung: CVS.EXE [login aborted]: could not find out home directory

Auf einer Windows Plattform muß die HOME Umgebungsvariable ihren (CVS) Benutzernamen und Passwort aufbewahren. In der Kommandozeile geben sie ein:

SET HOME=C:\MyHome

oder

SET HOME=C:\WINDOWS

oder

SET HOME=C:\WINDOWS\Profiles\YourLoginName

oder jeden anderen Ort, den sie wünschen.

Inzwischen erfolgte die Umstellung auf SVN (http://svn.freepascal.org/svn/lazarus/trunk_lazarus). Die CVS Daten werden nicht mehr aktualisiert und sollten daher nicht verwendet werden.

Wie kann ich meinem Programm einen XP Look geben wie Lazarus ihn hat?

If you have a myprogram.exe then create a file which called myprogram.exe.manifest and copy-paste this to the file:

<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<assembly xmlns="urn:schemas-microsoft-com:asm.v1" manifestVersion="1.0">
<assemblyIdentity processorArchitecture="*" version="1.0.0.0" type="win32" name="myprogram"/>
<description>programom</description>
<dependency>
  <dependentAssembly>
   <assemblyIdentity
     type="win32"
     name="Microsoft.Windows.Common-Controls"
     version="6.0.0.0"
     publicKeyToken="6595b64144ccf1df"
     language="*"
     processorArchitecture="*" />
  </dependentAssembly>
  </dependency>
</assembly>

Voila! XP looks.

Mitwirkende und Kommentare

This page has been converted from the epikwiki version.