Install Packages/zh CN

From Free Pascal wiki
Jump to navigationJump to search

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

概览

Due to popular demand here is a first attempt to create a small "Install package HOW-TO". 由于普遍的需求,这里有一个最初的尝试,建立一个小的“包如何安装”。

在安装辣子之后,很多新手想知道,哪里的组件能够操作数据库。你能看到一个数据源和一些数据感知组件,但是,哪里才是组件连接到数据库(服务器)和从数据库检索数据的地方呢?

好的,让我们看一看,是否我们能找到这些东西。

Files installed with Lazarus 辣子已安装文件

在Linux下,辣子默认安装在/usr/share/lazarus位置;在Mac OS X上,辣子默认安装在/usr/local/share/lazarus,在Windows上,安装位置你可以选择,比如G:/Lazarus。不管你把辣子安装在哪里,你总能发现一些子文件夹。就是这样,(按字母顺序排列)子目录看起来相当于是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. 如同你能看到的,那儿还有一些子目录,使我们联想起数据库。一个看起来是Interbase, 一个 mysql,一个 sqlite 还有一个 sqldb 文件夹。(译注:看不到这么多了,好几个组件被并入sqldb)。前三个是数据库连接组件,还有各自数据库的 Tdataset descendants。最后一个,sqldb,更普通,它有几部分组成:TSQLQuery (一个 TDataset) 和 TSQLTransaction 用来给所有数据库类型做连接的 TConnection。

本章内,我们要安装一个sqldb包,连同连接 Interbase。

The real work 实际工作

首先:为什么

在我们开始安装一个包之前,我要先讨论,为什么Lazarus不安装数据库连接组件。数据库连接组件需要客户端运行库(lib)可用,就是组件被应用的那台电脑。因为辣子并不支持动态连接(dynamic linking),所有库必须编译入IDE。这样,你不能指望每一个开发者都安装所有的数据库,默认(辣子)安装所有的连接组件并不现实。

Second: But Delphi ...? 其次:但是Delphi……

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

in the meantime all supported components.

Anything else? 还有别的吗?

Well that is all there is to it. You're now set to make your first program connecting to an Interbase server. See this sources to download a small example. If you have any questions, go to the lazarus forum or post it to the lazarus mailing list.

Compile an IDE with packages at command line 在命令行编译IDE的包

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. See here for details: Install IDE packages without the IDE. But the rest can be done on command line:

First build a normal IDE and LCL 首先建立一个普通IDE和LCL

 make clean all

Then compile the packages 然后编译包

The IDE can create a Makefile for a package (package editor -> compiler options -> compilation). The Makefile is updated on every compile of the package. Once you have this Makefile, go to every package directory and type 'make'.

Finally compile the IDE with the packages 最后编译包进入IDE

 make idepkg