FAQ - Frequently Asked Question
===============================

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

1. General
++++++++++

--------------------------------------------------------------------------------
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
# 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 if you use the following steps:

   1. You need a textual version of all form files (dfm)
      D4: created by copy/paste from ALT-F12
      D5: Native
   2. Create a file with lazres (in lazarus/tools)
      lazres yourform.lrs yourform.dfm
   3. Add the following initialization section to every unit with a form:

      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
Either your "Other sources" path or your FPC source path is not sufficient.

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 path to the lazarus sources is normally automatically set. Check
Run->Compiler Options->Search Paths->Other Sources
for
$(LazarusDir)/lcl;$(LazarusDir)/lcl/interfaces/$(LCLWidgetType)

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


--------------------------------------------------------------------------------
================================================================================


1. Linux
++++++++


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

--------------------------------------------------------------------------------
How can I debug lazarus and lcl on Linux?

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 Delphi 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>
All though you have installed the package <packagename> which provides
<some lib>, you also need the development package, normally called
<packagename>-dev


--------------------------------------------------------------------------------
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 svn:

$ svn checkout http://svn.freepascal.org/svn/lazarus/trunk 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".


--------------------------------------------------------------------------------
================================================================================


3. 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 SVN I get:
SVN.EXE [login aborted]: could not find out home directory
On a windows platform the HOME environment variable is required to store
your (SVN) username and password. From the command prompt issue:

SET HOME=C:MyHome
or
SET HOME=C:WINDOWS
or
SET HOME=C:WINDOWSProfilesYourLoginName
or
any other place you like

--------------------------------------------------------------------------------

