Difference between revisions of "Install Packages"

From Lazarus wiki
Jump to navigationJump to search
(→‎Overview: Database components present by default)
(Reworked. Removed db specific stuff including link to ib demo app; won't compile, errors with wrong components)
Line 14: Line 14:
 
== Files installed with Lazarus ==
 
== Files installed with Lazarus ==
  
Under Linux Lazarus gets installed by default in '''/usr/bin/lazarus''', on Mac OS X Lazarus is installed in '''/usr/local/share/lazarus''', and with Windows the installer gives you a choice where to install the files, as long as there are no spaces in its path. On my Windows PC Lazarus got installed in '''G:/Lazarus'''. Whatever the base path of your Lazarus installation is, there you will find some subdirectories. In this case the first (alphabetically) subdirectory looks rather promising as it is called '''components'''.
+
Under Linux Lazarus gets installed by default in '''/usr/bin/lazarus''', on Mac OS X Lazarus is installed in '''/usr/local/share/lazarus''', and with Windows the installer gives you a choice where to install the files, as long as there are no spaces in its path. On my Windows PC Lazarus got installed in '''G:/Lazarus'''. Whatever the base path of your Lazarus installation is, there you will find some subdirectories. In this case the first subdirectory looks rather promising as it is called '''components'''.
  
 
As you can see there are a few subdirectories there, which remind us of databases. One sees an '''Interbase''', a '''mysql''', a '''sqlite''' and a '''sqldb''' directory. The first three contain database connection components and TDataset descendants for the respective databases. The last one, '''sqldb''', is more generic, as it consists of TSQLQuery (a TDataset) and TSQLTransaction which are used for all types of databases and a T??Connection to make the connection to the database.
 
As you can see there are a few subdirectories there, which remind us of databases. One sees an '''Interbase''', a '''mysql''', a '''sqlite''' and a '''sqldb''' directory. The first three contain database connection components and TDataset descendants for the respective databases. The last one, '''sqldb''', is more generic, as it consists of TSQLQuery (a TDataset) and TSQLTransaction which are used for all types of databases and a T??Connection to make the connection to the database.
 
In this article we will install the sqldb package together with the connection for Interbase.
 
In this article we will install the sqldb package together with the connection for Interbase.
  
== The real work ==
+
== Adding packages using the IDE ==
=== First: the why ===
+
=== Adding known packages ===
Before we start installing a package I would like to discuss the why of Lazarus not installing database connection components. Database connection components need the client libraries to be available on the PC where the components are used. Because Lazarus does not currently support dynamic linking, all libraries have to be compiled into the IDE. As you cannot expect every developer to have all databases installed it is not possible to install the connection components by default.
+
Open "Package -> Install/Uninstall Packages".
 +
The list on the left shows already installed packages or packages marked for installation (which have a green plus sign in their icon). The list to the right shows packages that you can install.
 +
Simply double-click on a package in either list to move them to the other - and mark them for installation/uninstall.
  
=== Second: But Delphi ...? ===
+
Finally, click "Save and Rebuild" to rebuild the IDE and the packages.
Delphi also only installs the database components which are readily available on the computer (ADO components) and components which do not need any client libraries (BDE: Paradox, DBase) to be installed.
 
=== Third: Let's install some stuff ===
 
To install a package one goes to "Components -> Open Package File (.lpk)".
 
In the following dialog you navigate to '''/usr/share/lazarus/components/sqldb''' or the corresponding directory under OS X or Windows and choose the '''sqldblaz.lpk''' file. If everything works out as planned you will see the Package Manager. The Package Manager is showing a treeview with the files in the package and the required packages. Now press '''Compile''' if you don't want to install the component into the IDE, otherwise you should press '''Install'''. Next we get a warning about Lazarus only supporting static linked libraries and the question if you want to rebuild Lazarus. Just press Yes and sit back. Lazarus will be rebuilt, and depending on your configuration restarted.
 
  
If everything went well you'll see a new tab called '''SQLdb'''. This tab will contain <strike>two components a TSQLConnection and a TSQLQuery. What we need next is a Connection component. Once again go to Components -> Open Package File and navigate to '''/usr/share/lazarus/components/sqldb/interbase'''. Open the ibconnectionlaz.lpk file and again press Compile and Install and Yes. :)
+
You can also compile and install packages the IDE knows nothing about. See below.
  
Next time Lazarus is started the SQLdb tab also contains a component TIBConnection. </strike>
+
=== Adding new packages ===
 +
To install a new package one goes to "Components -> Open Package File (.lpk)".
 +
In our example scenario, in the following dialog you navigate to '''/usr/share/lazarus/components/sqldb''' or the corresponding directory under OS X or Windows and choose the '''sqldblaz.lpk''' file. If everything works out as planned you will see the Package Manager. The Package Manager shows a treeview with the files in the package and the required packages.
  
in the meantime all supported components.
+
If you don't want to install the component into the IDE, e.g. because it is a non graphical component, press '''Compile'''.
 +
Otherwise you should press '''Install'''. Next we get a warning about Lazarus only supporting static linked libraries and the question if you want to rebuild Lazarus. Just press Yes and sit back. Lazarus will be rebuilt, and depending on your configuration restarted.
  
== Anything else? ==
+
If everything went well you'll see a new tab called '''SQLdb'''. This tab will contain two components: a TSQLConnection and a TSQLQuery. What we need next is a Connection component. Once again go to Components -> Open Package File and navigate to '''/usr/share/lazarus/components/sqldb/interbase'''. Open the ibconnectionlaz.lpk file and again press Compile and Install and Yes. :)
Well that is all there is to it. You're now set to make your first program connecting to an Interbase server. See this [http://prdownloads.sourceforge.net/lazarus-ccr/IBdemo-20050328.zip?download sources] to download a small example. If you have any questions, go to the lazarus [http://www.lazarus.freepascal.org/index.php?name=PNphpBB2&file=index forum] or post it to the lazarus mailing list.
+
 
 +
Next time Lazarus is started the SQLdb tab also contains a component TIBConnection.
  
 
== Compile an IDE with packages at command line ==
 
== Compile an IDE with packages at command line ==
There is no command line tool yet, to configure and setup the IDE config files to add/remove packages. You must setup this with an IDE, copy the configs and adapt the path.  
+
There is no command line tool yet to configure and setup the IDE config files to add/remove packages. You must set up the packages with an IDE, copy the configs and adapt the path.  
 
See here for details: [[Install IDE packages without the IDE]].
 
See here for details: [[Install IDE packages without the IDE]].
But the rest can be done on command line:
+
But the rest can be done on the command line:
  
 
=== First build a normal IDE and LCL ===
 
=== First build a normal IDE and LCL ===
  make clean all
+
<syntaxhighlight lang="bash">
 +
make clean all
 +
</syntaxhighlight>
 +
 
 
=== Then compile the IDE with packages ===
 
=== Then compile the IDE with packages ===
  
This will build the packages to be installed, then the IDE and finally link all together:
+
This will build the packages that the config files say need to be installed, then the IDE and finally link them all together:
lazbuild --build-ide=
+
<syntaxhighlight lang="bash">
 +
lazbuild --build-ide=
 +
</syntaxhighlight>
  
 
The ''--build-ide'' parameter can take some options, for example -gh for heaptrc or '-gh -gt'.
 
The ''--build-ide'' parameter can take some options, for example -gh for heaptrc or '-gh -gt'.
 +
 +
== Questions ==
 +
If you have any questions, go to the lazarus [http://www.lazarus.freepascal.org/index.php?name=PNphpBB2&file=index forum] or post it to the Lazarus mailing list.
  
 
==See also==
 
==See also==

Revision as of 08:10, 16 May 2012

Deutsch (de) English (en) español (es) français (fr) magyar (hu) 日本語 (ja) português (pt) русский (ru) slovenčina (sk) 中文(中国大陆)‎ (zh_CN) 中文(台灣)‎ (zh_TW)

Overview

Due to popular demand here is a small "Install package HOW-TO".

We're going to look at installing database components, which weren't installed by default in old Lazarus versions. They are still not present in the minimal IDE, but are there in the normal IDE. Though database components are nowadays present in Lazarus by default, the concepts of finding and installing packages can still be nicely illustrated.

We are going to look for and install the components to connect to a database (server) and to retrieve data from this database?

Well, let's have a look to see if we can find some of this stuff.

Files installed with Lazarus

Under Linux Lazarus gets installed by default in /usr/bin/lazarus, on Mac OS X Lazarus is installed in /usr/local/share/lazarus, and with Windows the installer gives you a choice where to install the files, as long as there are no spaces in its path. On my Windows PC Lazarus got installed in G:/Lazarus. Whatever the base path of your Lazarus installation is, there you will find some subdirectories. In this case the first subdirectory looks rather promising as it is called components.

As you can see there are a few subdirectories there, which remind us of databases. One sees an Interbase, a mysql, a sqlite and a sqldb directory. The first three contain database connection components and TDataset descendants for the respective databases. The last one, sqldb, is more generic, as it consists of TSQLQuery (a TDataset) and TSQLTransaction which are used for all types of databases and a T??Connection to make the connection to the database. In this article we will install the sqldb package together with the connection for Interbase.

Adding packages using the IDE

Adding known packages

Open "Package -> Install/Uninstall Packages". The list on the left shows already installed packages or packages marked for installation (which have a green plus sign in their icon). The list to the right shows packages that you can install. Simply double-click on a package in either list to move them to the other - and mark them for installation/uninstall.

Finally, click "Save and Rebuild" to rebuild the IDE and the packages.

You can also compile and install packages the IDE knows nothing about. See below.

Adding new packages

To install a new package one goes to "Components -> Open Package File (.lpk)". In our example scenario, in the following dialog you navigate to /usr/share/lazarus/components/sqldb or the corresponding directory under OS X or Windows and choose the sqldblaz.lpk file. If everything works out as planned you will see the Package Manager. The Package Manager shows a treeview with the files in the package and the required packages.

If you don't want to install the component into the IDE, e.g. because it is a non graphical component, press Compile. Otherwise you should press Install. Next we get a warning about Lazarus only supporting static linked libraries and the question if you want to rebuild Lazarus. Just press Yes and sit back. Lazarus will be rebuilt, and depending on your configuration restarted.

If everything went well you'll see a new tab called SQLdb. This tab will contain two components: a TSQLConnection and a TSQLQuery. What we need next is a Connection component. Once again go to Components -> Open Package File and navigate to /usr/share/lazarus/components/sqldb/interbase. Open the ibconnectionlaz.lpk file and again press Compile and Install and Yes. :)

Next time Lazarus is started the SQLdb tab also contains a component TIBConnection.

Compile an IDE with packages at command line

There is no command line tool yet to configure and setup the IDE config files to add/remove packages. You must set up the packages with an IDE, copy the configs and adapt the path. See here for details: Install IDE packages without the IDE. But the rest can be done on the command line:

First build a normal IDE and LCL

make clean all

Then compile the IDE with packages

This will build the packages that the config files say need to be installed, then the IDE and finally link them all together:

lazbuild --build-ide=

The --build-ide parameter can take some options, for example -gh for heaptrc or '-gh -gt'.

Questions

If you have any questions, go to the lazarus forum or post it to the Lazarus mailing list.

See also