Lazarus Faq

From Lazarus wiki
Revision as of 09:50, 19 February 2005 by Vincent (talk | contribs) (changed format (as an example))

Contents

Lazarus FAQ - Frequently Asked Questions

This is a summary of the FAQ at www.freepascal.org. See there for a complete and uptodate list.__

General

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.

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

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

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.
  • remove {$R *.xfm} directive
  • add an initialization section to 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

the password is 'cvs'

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

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.

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

End of Lazarus FAQ

Contributors and Comments

Please see the [SiteUpdateLog|] for a history of changes and additions to this page http://lazarus-ccr.sourceforge.net/index.php?wiki=LazarusFaq