Difference between revisions of "Lazarus Faq/de"

From Lazarus wiki
Jump to navigationJump to search
Line 32: Line 32:
 
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.
 
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.
  
=== I can't compile Lazarus ===
+
=== Ich kann Lazarus nicht kompilieren. ===
  
 
# Check if the compiler has the correct version
 
# Check if the compiler has the correct version

Revision as of 19:27, 23 August 2005

Allgemein

Wo kann ich mehr FAQ 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.

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

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

Using the IDE

How can I use "identifier completion"?

You can invoke identifier completion by pressing [ctrl][space]. Under the menu item Environment -> Editor Options -> Code Tools -> Automatic Features you can set how quick this should happen automatically.

Linux

How can I debug on Linux without the IDE?

First of all you need a debugger. gdb is the standard debugger under linux and there are several GUI-frontends available. One common frontend is ddd, which is part of most common distributions. To compile lazarus/lcl with debug-information you should then use the following commands to start a debug session:

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

Be warned however, that ddd is not as comfortable as e.g. the Lazarus debugger. 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.

I can debug now but ddd does not find my sources or complains that they contain no code. Whats that?

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

How can I convert a kylix 2 project into a lazarus project?

Nearly the same way as converting a Kylix project into a Delphi/VCL project.

The LCL (Lazarus Component Library) tries to be compatible to Delphis VCL. Kylix CLX tries to be QT compatible. Here are some general hints:

  • rename all used CLX Q-units like QForms, QControls, QGraphics, ... into their VCL counterparts: Forms, Controls, Graphics, ...
  • Add LResources to the uses section of every form source
  • rename or copy all .xfm files to .lfm files.
  • rename or copy .dpr file to .lpr file.
  • remove {$R *.res} directive
  • remove {$R *.xfm} directive
  • add {$mode objfpc}{$H+} or {$mode delphi}{$H+} directive to .pas and .lpr files
  • add an initialization section to the end of each form source and add an include directive for the .lrs file (lazarus resource file):
 initialization
   {$I unit1.lrs}
The .lrs files can be created via the lazres tool in: (lazarusdir)/tools/lazres.
For example: ./lazres unit1.lrs unit1.lfm
  • Fix the differences. The LCL does not yet support every property of the VCL and the CLX is not fully VCL compatible.

When compiling lazarus the compiler can not find a unit. e.g.: 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.

I have installed the binary version, but when compiling a simple project, lazarus gives: 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

When I try to make Lazarus I get:

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

You need to upgrade your make.

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.

When I try to login at CVS I get: CVS.EXE [login aborted]: could not find out home directory

On a windows platform the HOME environment variable is required to store your (CVS) username and password. From the command prompt issue:

SET HOME=C:\MyHome

or

SET HOME=C:\WINDOWS

or

SET HOME=C:\WINDOWS\Profiles\YourLoginName

or any other place you like

How can I give my program an XP look like lazarus has?

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.

Contributors and Comments

This page has been converted from the epikwiki version.