Difference between revisions of "Lazarus Faq/fr"

From Free Pascal wiki
Jump to navigationJump to search
Line 100: Line 100:
 
* Vous pouvez également essayer de changer l'ensemble de composants graphiques actuellement choisi pour le projet. Par exemple , l'exemple de projet "objectinspector" qui accompagne Lazarus paramétré à gtk par défaut . Compiler ce projet va surement vous donner "Can't find unit interfaces" dans la plate-forme Windows. Changer le jeux de composants graphiques à default(Win32) dans Projet|Options du compilateur ... | Type composant graphique LCL (divers) devrait fixer ce problème.
 
* Vous pouvez également essayer de changer l'ensemble de composants graphiques actuellement choisi pour le projet. Par exemple , l'exemple de projet "objectinspector" qui accompagne Lazarus paramétré à gtk par défaut . Compiler ce projet va surement vous donner "Can't find unit interfaces" dans la plate-forme Windows. Changer le jeux de composants graphiques à default(Win32) dans Projet|Options du compilateur ... | Type composant graphique LCL (divers) devrait fixer ce problème.
  
=== When I try to compile delphi projects under lazarus, I have an error ===
+
=== Quand j'essaye de compiler des projets Delphi sous  lazarus, J'ai une erreur  ===
==== at the line :{$R *.DFM} How can I solve this problem ? ====
+
==== à la ligne  :{$R *.DFM} Comment puis je résoudre ce problème ? ====
  
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:
+
Lazarus (ou mieux Linux) ne sait rien des ressources, ainsi vous ne pouvez pas les employer avec la manière de faire de  Delphi/win32. Cependant Lazarus emploie une méthode assez compatible avec ceci. Vous pouvez encore employer vos plans de fiche Delphi (fichiers .dfm) si vous employez les étapes suivantes :
  
*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.
+
*Vous avez besoin d'une version textuelle des fichiers .dfm. D5 et au delà font ceci par défaut. Si vous avez des fichiers plus anciens : ALT-F12 pour voir le plan de fiche comme du texte et coller/copie. Quand vous avez un texte du fichier .dfm, copiez le juste vers un fichier .lfm.
*Create a file with lazres (in lazarus/tools) lazres yourform.lrs yourform.lfm
+
*Créer un fichier avec  lazres (dans  lazarus/tools): lazres yourform.lrs yourform.lfm
*Add the following initialization section to
+
*Ajouter la section suivante d'initialisation à
  
 
       initialization
 
       initialization
 
       {$I yourform.lrs}
 
       {$I yourform.lrs}
  
Please keep in mind that not all properties in the dfm are supported yet by
+
SVP, gardez à l'esprit que toutes les propriétés dans le fichier dfm ne sont toujours pas supportées par
lazarus, so you might get a crash.
+
lazarus, ainsi vous pourriez obtenir un crash.
  
 
==== 'Identifier not found LazarusResources'. ====
 
==== '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.
+
En créant une fiche Lazarus ajoute automatiquement quelques unités supplémentaires à la section uses de l'unité de votre fiche. Pendant la conversion d'une unité delphi vers une unité Lazarus ceci ne se produit pas . Ainsi vous le besoin d'ajouter LResources à la section Uses de l'unité de la fiche.
  
 
=== When accessing events of objects e.g. the onclick event of a button I get the following error. ERROR unit not found: stdCtrls ===
 
=== When accessing events of objects e.g. the onclick event of a button I get the following error. ERROR unit not found: stdCtrls ===

Revision as of 21:37, 30 June 2007

العربية (ar) Deutsch (de) English (en) español (es) français (fr) magyar (hu) italiano (it) 日本語 (ja) 한국어 (ko) português (pt) русский (ru) slovenčina (sk) 中文(中国大陆)‎ (zh_CN) 中文(台灣)‎ (zh_TW)

Cette FAQ est copié de la FAQ du site www.freepascal.org, car il est plus facile maintenir et prolonger ce document wiki.

General

Où peux je trouver plus de FAQ ?

Voir le site web officiel. Il y a une autre FAQ aussi.

Pourquoi les binaries produits sont si grands ?

Les binaries sont grands parce qu'ils contiennet beaucoup d'information de deboggage nécessaire pour l'utilisation de gdb (GNU Debugger).

Le compilateur a une option pour enlever l'information de deboggage de l'exécutable (-Xs),mais en raison d'un bogue dans le compilateur(version 2.0.2 et plus tôt), ceci ne fonctionne pas correctement . Cela a été fixé dans la version de développement du compilateur .

Vous pouvez employer un programme appelé "strip" pour enlever les symboles de deboggage du fichier exécutable. Il est situé sous le répertoire de Lazarus lazarus\pp\bin\i386-win32\.

Tapeze juste "strip --strip-all <votre fichier exécutable avec le chemin >" sur la ligne de commande .

Si vous voulez rendre votre programme encore plus petit , vous devriez essayer UPX aussi . UPX est un très bon compresseur d'exe. It includes no memory overhead due to in-place decompression. Il a également une décompression très rapide (~10 MB/sec sur un Pentium 133).

Pour employer upx tapez juste "upx <votre fichier exécutable avec le chemin>" sur la ligne de commande .

après avoir employé à la fois strip et upx un simple GUI programmé avec Lazarus donne:

  • ~ 700kb sur Linux
  • ~ 420kb sur Windows

Une réponse plus détaillée avec les inconvénients d'utiliser UPX est donné sur Considérations de taille.

Il est également important de noter que le logiciel "bonjour le monde" de lazarus inclut déjà une quantité énorme de fonctionnalisés . Il inclut :

  • Une librairie de traitement XML
  • Une librairie de traitement d'images pour les fichiers png, xpm, bmp et ico
  • Presque tous les composants graphiques de la bibliothèque de composants de Lazarus(LCL)
  • Toutes les Bibliothèques Runtime de Free Pascal

Ainsi il est très grand , mais il inclut déjà presque tout ce qu'une application non triviale du monde réel aura besoin.

La taille de l'executable Lazarus commence grand , mais se développe très lentement , en raison du compilateur Free Pascal et la façon dont les fiches lazarus opèrent. Un projet c++ (juste un exemple , mais s'applique à d'autres langues/outils aussi ) commence très petits sur bonjour le monde, mais se développe rapidement exponentiellement quand vous avez besoin de fonctionnalités pour écrire une application non triviale .

Lazarus vs cpp.png

Pourquoi le linkage est il si lent sur Windows?

D'une manière générale, la compilation sur Windows prend plus de temps que sur d'autres plate-formes parce que l'éditeur de liens de GNU utilisé par FreePascal est lent sur cette plate-forme . Ce problème affecte seulement Windows , et est seulement mauvais sur les ordinateurs relativement vieux (moins que 1Ghz) et sur ceux avec peu de RAM (128MB ou moins).

En outre, si vous liez intelligement la LCL, le linkage sera beaucoup plus lent. Une étude à ce sujet est localisée ici : Taille de fichier et lien intelligent

Un éditeur de liens interne a été développé , et est prêt , mais sera seulement disponible quand Free Pascal 2.2 sera réalisé (naturellement il est également disponible via subversion). Il diminue nettement le temps linkage.

Note: Dans la version 2.1.1 Windows emploie un éditeur de liens interne pour win32/64/ce qui accélère le processus un peu. Une recompilation de Lazarus mange alors environ 280MB.

Ai je besoin de ppc386.cfg ou fpc.cfg?

Vous avez besoin seulement de fpc.cfg. De cette façon le compilateur sait où trouver les bibliothèques .

Comment je compile lazarus?

Faire quelque chose comme ça:

$ cd lazarus
$ make clean all

Comment je construis d'autres projets basés sur la LCL

Si vous ne pouvez pas employer l'IDE pour construire vos applications, ajouter les lignes suivantes à la fin de votre fpc.cfg

  # searchpath for other toolkits (Linux)
  -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/{YourToolKit}
  # searchpath for other toolkits (Windows)
 -Fu/{YourLazarusDirectory}/components/units/{YourToolKit}
Où {YourToolKit} peut être gtk2, gnome, qt ou win32 et executer:
ppc386 your.project.pp

Conseil : Ne pas oublier d'installer les paquets de développement pour votre trousse à outils autrement vous pourriez recevoir quelque chose comme: Linker message: cannot find -l.

Quelle version de FPC est exigé ?

FPC Version 2.0.4 a été réalisée , et c'est la version recommandée. Vous pouvez également employer la version svn de fpc 2.0.5 et 2.1.x.

Je ne peux pas compiler Lazarus

  1. Vérifier si le compilateur a la version correcte
  2. Vérifier si les bibliothèques (fpc) sont de la même version .
  3. Vérifier si vous avez un fichier fpc.cfg et pas de vieux fichier ppc386.cfg
  4. Vérifier également les FAQs sur la dépendance par rapport aux Systèmes d'exploitations

Quand j'essaye de compiler un projet , J'ai une erreur

"Cannot find Unit interfaces". Comment peux je résoudre ceci ?

Cette unité compilée peut être trouvé dans le répertoire {LazarusDir}\lcl\units\{TargetCPU}-{TargetOS}\{LCLWidgetSet}\interfaces.ppu.

S'assurer, qu'elle est seulement là. Si vous avez des versions multiples de interfaces.ppu, alors vous avez probablement une configuration fausse (par exemple vous avez ajouté un répertoire lcl à un chemin de recherche ). Enlever tous les interfaces.ppu, exceptés celui dans le répertoire ci-dessus .

Si vous choisissiez un ensemble de composants graphiques différent que celui que vous avez utilisé pour construire lazarus, vous devez construire la bibliothèque LCL pour cet ensemble de composants graphiques.

Si elle est là , mais vous obtenez cette erreur , vous employez un compilateur/rtl différent pour compiler votre projet que celui employé pour la compilation de votre IDE Lazarus. Vous pouvez faire une des propositions suivantes

  • Reconstruire la bibliothèque LCL (ou Lazarus complètement) avec le compilateur choisi dans les options d'Environnement. Vous pouvez faire ceci avec Outils -> Construire Lazarus. Avant de faire ceci ,vérifier les paramètres courants dans Outils -> Configurer "Construire Lazarus".
  • Changer le compilateur dans les options d'environnement vers celui que vous aviez utilisé pour compiler Lazarus. Regarder soigneusement également dans les options d'environnement pour voir si vous utilisez le chemin correct pour le répertoire de Lazarus Directory et le repertoire de FPC. Vérifier qu'il y a seulement une version du fichier de configuration du compilateur fpc.cfg - il devrait résider dans le répertoire /etc/ pour les systèmes Linux/Unix ou dans le même répertoire que le compilateur fpc pour les systèmes Windows. Essayez d'exécuter "fpc -vt bogus" pour vérifier quel fichier fpc.cfg est employé dans votre système . Des copies scélérates s'introduisent souvent si vous avez mis à jour votre compilateur à une nouvelle version ; ils peuvent être trouvés dans votre répertoire local ou dans le même répertoire que celui dans lequel vous avez construit votre nouveau compilateur . SUPPRIMER CES DERNIERS !!
  • Vous pouvez également essayer de changer l'ensemble de composants graphiques actuellement choisi pour le projet. Par exemple , l'exemple de projet "objectinspector" qui accompagne Lazarus paramétré à gtk par défaut . Compiler ce projet va surement vous donner "Can't find unit interfaces" dans la plate-forme Windows. Changer le jeux de composants graphiques à default(Win32) dans Projet|Options du compilateur ... | Type composant graphique LCL (divers) devrait fixer ce problème.

Quand j'essaye de compiler des projets Delphi sous lazarus, J'ai une erreur

à la ligne :{$R *.DFM} Comment puis je résoudre ce problème ?

Lazarus (ou mieux Linux) ne sait rien des ressources, ainsi vous ne pouvez pas les employer avec la manière de faire de Delphi/win32. Cependant Lazarus emploie une méthode assez compatible avec ceci. Vous pouvez encore employer vos plans de fiche Delphi (fichiers .dfm) si vous employez les étapes suivantes :

  • Vous avez besoin d'une version textuelle des fichiers .dfm. D5 et au delà font ceci par défaut. Si vous avez des fichiers plus anciens : ALT-F12 pour voir le plan de fiche comme du texte et coller/copie. Quand vous avez un texte du fichier .dfm, copiez le juste vers un fichier .lfm.
  • Créer un fichier avec lazres (dans lazarus/tools): lazres yourform.lrs yourform.lfm
  • Ajouter la section suivante d'initialisation à
     initialization
     {$I yourform.lrs}

SVP, gardez à l'esprit que toutes les propriétés dans le fichier dfm ne sont toujours pas supportées par lazarus, ainsi vous pourriez obtenir un crash.

'Identifier not found LazarusResources'.

En créant une fiche Lazarus ajoute automatiquement quelques unités supplémentaires à la section uses de l'unité de votre fiche. Pendant la conversion d'une unité delphi vers une unité Lazarus ceci ne se produit pas . Ainsi vous le besoin d'ajouter LResources à la section Uses de l'unité de la fiche.

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 -> Environment Options -> Files -> FPC source directory

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.

What is the meaning of the various file extensions used by Lazarus?

The Lazarus Tutorial/fr#Les fichiers de Lazarus explains some extensions by an example. Here is a brief list:

*.lpi
Lazarus Project Information file (stored in XML; contains project-specific settings)
*.lpr
Lazarus Program file; contains Pascal source of main program
*.lfm
Lazarus Form file; contains configuration information for all objects on a form (stored in a Lazarus-specific format; the actions are described by Pascal source code in a corresponding *.pas file)
*.pas or *.pp
Unit with Pascal code (typically for a form stored in a corresponding *.lfm file)
*.lrs
Lazarus Resource file (this is a generated file; not to be confused with a Windows resource file).
This file can be created with lazres tool (in directory Lazarus/Tools) using commandline: lazres myfile.lrs myfile.lfm
*.ppu
Compiled unit
*.lpk
Lazarus package information file. (stored in XML; contains package-specific settings)

Lien titre

I have fixed/improved lazarus. How can I add my changes to the official lazarus source?

Create a patch and send it to the developers. For details see Creating A Patch.

When I do var mytext: text; to declare a text file, I get "Unit1.pas(32,15) Error: Error in type definition". How can I fix this?

The TControl class has a Text property. In a method of a form, that has higher visibility, the Text type from the system unit. You can use the TextFile type, which is just an alias for the Text type or you can add the unit to the type definition.

var
  MyTextFile: TextFile;
  MyText: System.Text;

A similar name clash exists with assigning and closing a text file. TForm has a assign and a Close method. You can use AssignFile and CloseFile or add the unit name System.

I get an error when using Printer.BeginDoc

The unit Printers must be added to the uses section.

The Printer4Lazarus package must be added to your project requirement in the IDE under: Project|Project Inspector|Add|New Requirement|Package Name:

If the package Printer4Lazarus package is not in the list when opening the dropdown box it must be installed. The package is part of the Lazarus installation and can be found in: [lazarus installed directory]\components\printers

If you used the default installation directories [lazarus installed directory] is:

  • Windows: c:\lazarus
  • Linux: /usr/lib/lazarus

Where is ... defined

Virtual key constants

Virtual key constants are defined in LCLType. Add LCLtype to your uses.

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) NOTE: This has changed as of late. Newest ports have gtk-12 and glib-12 as well. You might stumble on this problem, since FPC requires the "-less" ones, you will need to symlink them like this:
[]# cd /usr/local/lib && ln -s libglib-12.so libglib12.so
[]# cd /usr/X11R6/lib && ln -s libgtk-12.so libgtk12.so
[]# cd /usr/X11R6/lib && ln -s libgdk-12.so libgdk12.so
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.
  • Add "Interfaces" to the uses section in the .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 (2.0.4 or higher)

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'
Remove any ppc386.cfg as it is really obsolete.

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/$fpcversion/units/$fpctarget
   -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/rtl
   -Fu/usr/lib/fpc/$fpcversion/units/$fpctarget/*
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/$fpctarget
 -Fu(lazarus_source_directory)/lcl/units/$fpctarget/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/$fpcversion/units/i386-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. Please, try to move the sources into a non NFS directory and compile there.

8. If you are still not succeeded try to use samplecfg script as follows:

# cd /usr/lib/fpc/version/

# ./samplecfg /usr/lib/fpc/version /etc

Note! Do not put - / - after etc because if you do that the system will create a file - /etc/fpc.cfg/fpc.cfg. In fact we want that samplecfg make a file - /etc/fpc.cfg - not the folder /etc/fpc.cfg.

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:

 $ bash
 $ svn checkout http://svn.freepascal.org/svn/lazarus/trunk lazarus
 $ cd lazarus
 $ make clean all

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 (or /opt/gnome/lib64 for 64 bits), which is not in the standard lib path. Simply add it to your /etc/fpc.cfg. (-Fl/opt/gnome/lib).

Lazarus crashes with runtime error 211 after I installed a component

After I installed a component, Lazarus crashes with the following message:

Threading has been used before cthreads was initialized.
Make cthreads one of the first units in your uses clause.
Runtime error 211 at $0066E188

How can I fix this?

Your freshly installed component is using threads. Fpc on *nix doesn't automatically include threading support, but it must be intialized. This initialization is done in the cthreads unit. Every application using the component needs to add this unit to the uses clause of the main program. Lazarus itself is no exception. This can be done in two ways:

1) Change the source of ide/lazarus.pp: add the cthreads as first unit to the uses clause, so that is looks like this:

uses
  //cmem,
  cthreads, 
  {$IFDEF IDE_MEM_CHECK}
...

and rebuild lazarus.

2) In order to avoid modifying lazarus.pp file, a fpc compiler option could be used. Once package that uses threads has been compiled, open menu Tools->Configure "build Lazarus". Configure "build Lazarus" dialog will be shown, in field "Options:" type -Facthreads and then press "OK" button. The next step is to install the package. Lazarus will be built with option -Facthreads which means that it will treat main program as if unit cthreads where first in uses clause.

Hint: Maybe your old (non-crashing) lazarus executable is stored as lazarus.old in the same directory as the crashing lazarus executable.

When I run a program with threads I get runtime error 232

The complete error message is:

This binary has no thread support compiled in.
Recompile the application with a thread-driver in the program uses
clause before other units using thread.
Runtime error 232

Solution: Add cthreads as first unit to the uses clause of your main program, usually the .lpr-file.

I have Ubuntu Breezy and my fonts in Lazarus IDE look too big

If Lazarus is compiled with Gtk1.2, the settings in Gnome Preferences/Font don't have any effect as they are related to Gtk2. You could try this solution: Create a file named .gtkrc.mine in your home directory (if it's not already there) and add these lines to it:

style "default-text" {
       fontset = "-*-arial-medium-r-normal--*-100-*-*-*-*-iso8859-1,\
                  -*-helvetica-medium-r-normal--*-100-*-*-*-*-*-*"
}

class "GtkWidget" style "default-text"

How can my gtk programs use custom rc files?

Option a) Name the rc file yourprogram.gtkrc and put it in the same directory where the executable is.

Option b) Use unit GtkInt and call GTKWidgetSet.SetRCFilename('your_preferred_rc_file'); Best done before Application.Initialize in the .lpr file with {$IFDEF LCLGtk}.

I have Ubuntu and I cannot compile for Gtk2 due to missing libraries

Ubuntu has a problem with not creating all the symbolic links that you'll need even when the libraries are installed. Make sure that all missing libraries when trying to link for Gtk2 have their appropriate links. For instance, you might need to do:

cd /usr/lib
sudo ln -s libgdk-x11-2.0.so.0 libgtk-x11-2.0.so

Make sure that the [whatever].so symbolic links are created and point to the actual libraries.

How can I compile a program for Gtk2?

At the moment, the Gtk2 compiled IDE is a little unstable, but you can compile software for Gtk2 using the Gtk1 IDE.

To start with recompile LCL for Gtk2. Go to the menu "Tools"->"Configure Build Lazarus" and set LCL to clean+build and everything else to none.

Now click Ok and go to the menu "Tools"->"Build Lazarus"

Now you can compile your software with Gtk2 going on the Compiler options and changing the widgetset to Gtk2.

I get this message: "[WARNING] ** Multibyte character encodings (like UTF8) are not supported at the moment."

Since revision 10535 (0.9.21) this message doesn't exist anymore. Previously it was used to warn that a UTF-8 encoding was used. The internal keyhandling routines for the gtk1 widgetset couldn't handle such encoding for keypresses, with the result that keypresses with for instance accented chars were not or wrong detected.

(original text for older versions of lazarus)
This warning message indicates that your locale enconding is set to utf-8. If you are using Gtk 1 this can be a serious problem and prevent the correct working of Lazarus or software created with Lazarus.

To work around this, just change your locale to a non utf-8 before executing the program on the command line, like this:

export LC_CTYPE="pt_BR"
export LANG="pt_BR"
export LANGUAGE="pt_BR"
./lazarus

Substitute pt_BR with the locale for your country. You can create a script to automate this.

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.


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.

When I run Windows program created in Lazarus it starts with a DOS window

Specify the -WG argument (Windows GUI) on the command line of the compiler or in the Lazarus IDE check the Windows GUI check box on the compiler options dialog box (Project menu -> Compiler Options -> Linking -> target OS Specific options.

Licensing

Can I make commercial applications with Lazarus ?

Yes, the LCL is licensed under the LGPL with an exception, which allows you to link to it statically without releasing the source of your application. Modifications and enhancements to the LCL must be distributed with source. Lazarus, the IDE, is licensed under the GPL.

Can I make commercial plug-ins for Lazarus ?

Yes, the IDEIntf part of the IDE is licensed under the LGPL with the same exception, so that shared data structures in this part will not force you to license your plug-in or design-time package under the GPL. You are free to choose a plug-in of any license; we don't want to limit your choice. Therefore non-GPL compatible plug-ins are allowed. Note that it's not allowed to distribute a precompiled Lazarus with these non-GPL-compatible plugins included statically; however, we do not see this as a severe limitation, since recompiling Lazarus is easy.

Contributors and Comments

This page has been converted from the epikwiki version.