首页 > 其他分享 >安装和使用delphi最后的余辉:lazarus集成编译环境@FreeBSD

安装和使用delphi最后的余辉:lazarus集成编译环境@FreeBSD

时间:2024-05-27 20:32:40浏览次数:14  
标签:lazarus fpc delphi Free source Pascal Lazarus FreeBSD

遥想当年,最牛最流行的两个编程IDE是Delphi和Visual Basic,结果这么多年下来,VB已经没有往昔的热度,而Delphi也已经消亡在历史的长河中。不过Delphi的精神没消失,lazarus坚守delphi的编程风格,散发delphi最后的余辉。

Lazarus介绍

Lazarus是一个基于Free Pascal的跨平台集成开发环境(IDE),主要用于快速应用程序开发(RAD)。

  • Lazarus被设计为Delphi的开源替代品,它利用Free Pascal编译器,支持多种处理器架构和操作系统。
  • Lazarus的设计目标是应用Free Pascal,因此所有Free Pascal能运行的平台,Lazarus也可以运行。

Lazarus官网:Lazarus Homepage

安装Lazarus

在FreeBSD下可以直接使用pkg安装 lazarus:

pkg install lazarus-gtk2

提示:

The process will require 2 GiB more space.
229 MiB to be downloaded.
说实话,比我想像中大一点,不过我喜欢

安装完成后,提示:

Message from lazarus-gtk2-3.2.0_1:

--
The Lazarus RAD was installed

1) You can run it using:

   # lazarus

2) The first time that lazarus is running, you should set the path to fpc
   source directory at lazarus configuration environment. Also it could be
   setting later.

3) Now you can obtain freepascal source installing lang/fpc-source port or
   package

   It will be extracted to /usr/local/share/fpc-source-X.X.X

4) You can use /usr/local/bin/gdb debugger instead of gdb installed debugger
   installed from base system. Lazarus works better with this version.

5) We can use the following ports for aplications that depend of lazarus
   and these can be built with an interface different than lazarus has compiled
   by default:

   editors/lazarus
   editors/lazarus-devel
   editors/lazarus-qt5
   editors/lazarus-qt5-devel
   editors/lazarus-qt6
   editors/lazarus-qt6-devel

   You can added those ports if you want support for gtk2, qt5 or qt6
   interfaces. Please look at net-p2p/transmission-remote-gui like a example of
   how use it

6) If you want built apps using devel version of lazarus, you must add the
   following into /etc/make.conf file

   WANT_LAZARUS_DEVEL=  yes

   It is neccesary for use devel version of lazarus (gtk2, qt5 or qt6)

   editors/lazarus-devel
   editors/lazarus-qt5-devel
   editors/lazarus-qt6-devel

7) Enjoy it ;)
pkg: Package database is busy while closing!

注意它提示了fpc的位置,比如在这里:/usr/local/share/fpc-source-3.2.2

后面启动lazarus之后需要配置。 

启动lazarus

在启动界面里有小报错,说需要设置rpc路径

前面提示里写了路径,也可以手动找到rpc路径,

在启动界面里设置fpc源代码位置的目录:/usr/local/share/fpc-source-3.2.2/

调试器设置如果报错,也需要重新设置了一下:/usr/local/bin/gdb 

终于能进入编辑界面了,多少年没有看见这个delphi的界面了啊!

试了一下,果然制作gui界面还是那么简单方便啊。不过我对pascal不太熟,所以只是怀旧看一下。 

最新好消息,竟然有python插件

在“软件包”-“在线软件包”里,搜索python,可以搜到python for lazarus ,安装

不过没有使用成功,就不费劲去整了。

这里有说明,大家可以看一下:Using Python in Lazarus on Windows/Linux - Free Pascal wiki

Lazarus实践

这个项目就是Lazarus的,可以实践一下:https://github.com/dajingshan/miniframe

对Visual Basic用户专门的学习资料:Pascal for Visual Basic users - Free Pascal wiki 

运行项目

创建了一个项目,在form上放置一个按钮和一个Label,然后在点击按钮处写代码:

procedure TForm1.Button1Click(Sender: TObject);
begin
  //Label1.Caption:= "hello world ";
  Caption:='My first Form';  //Caption of Form1 is changed (text in formhead)
  //or
  Button1.Caption:='Hello';  //Caption of button is changed (shown text of button)
  Label1.Caption:='hello';
end;                     

 运行后,点击按钮,form的名字和按钮、Label上的字都变了,运行成功!

跟python比起来,感觉Free pascal 语法有如下几个注意的地方:

代码块需要用begin 开头,end; 结尾。 赋值需要用:= ,另外就是字符串需要用单引号,而不像python还可以使用双引号(这里若有错误请告知)。具体语法可以到Free Pascal官网看一下:Free Pascal - Advanced open source Pascal compiler for Pascal and Object Pascal - Home Page

总结:

Lazarus果然很棒! 让人又重温了当年激情燃烧的岁月感。

不过现在主流还是WEB+人工智能,估计Lazarus也只是Delphi最后的余辉罢了。

调试

启动lazarus的时候有小报错

目录:/usr/local/share/lazarus-3.2.0/

错误:未找到目录 rtl 您可以从 http://sourceforge.net/projects/lazarus/?source=directory 下载 FPC 和 FPC 的源代码

FreeBSD下有FPC的包,所以安装起来很简单,先search一下

pkg search fpc
pkg: No SRV record found for the repo 'FreeBSD'
fpc-3.2.2_10                   Free Pascal compiler with Turbo and Delphi compatibility
fpc-devel-3.3.1.20240503       Free Pascal compiler with Turbo and Delphi (devel)
fpc-devel-source-3.3.1.20240503 Free Pascal compiler with Turbo and Delphi compatibility (source)
fpc-docs-3.2.2                 Free Pascal compiler Adobe Acrobat(tm) documentation
fpc-source-3.2.2_5             Free Pascal compiler with Turbo and Delphi compatibility (source)
pdfpc-4.6.0_6                  Keynote-like multi-monitor presentation viewer
然后pkg 安装

pkg install fpc-3.2.2_10 fpc-source-3.2.2_5

但是说这两个已经安装好了。

终于找到了位置:/usr/local/share/fpc-source-3.2.2/ 

设置好即可。

标签:lazarus,fpc,delphi,Free,source,Pascal,Lazarus,FreeBSD
From: https://blog.csdn.net/skywalk8163/article/details/139219545

相关文章

  • Delphi 防止程序重复运行
    Delphi防止程序重复运行,D11.3/D12调试通过代码如下红色部分即可programProMain;uses Vcl.Forms,Windows,SysUtils, DmPasin'DmPas.pas'{DM:TDataModule}, uFrmMainin'uFrmMain.pas'{FrmMain};{$R*.res}VarhMutex:HWND;//把HWND换成Cardinal,因为Cre......
  • Delphi CxGrid/CxDBTreeList等将排序筛选条件改为中文方法
    Delphi CxGrid/CxDBTreeList等将排序筛选条件改为中文方法一、加入cxLocalizer控件二、在FormCreate里加入以下代码procedureTForm1.FormCreate(Sender:TObject);begin cxLocalizer1.LoadFromResource(HInstance); cxLocalizer1.Language:='中文(简体,中国)';......
  • Xfce4桌面背景和桌面图标消失问题解决@FreeBSD
    问题:Xfce4桌面背景和桌面图标消失以前碰到过好几次桌面背景和桌面图标消失,整个桌面除了上面一条和下面中间的工具条,其它地方全是黑色的问题,但是这次重启之后也没有修复,整个桌面乌黑一片,啥都没有,用起来特别不得劲,于是开始修复。修复过程咨询文心,建议这样设置:检查壁纸设置:......
  • IDocList/IDocDict JSON for Delphi and FPC
    IDocList/IDocDictJSONforDelphiandFPC【英文原文】多年来,我们的开源mORMot框架提供了多种方式,以处理在运行时定义的任何数组/对象文档组合,例如通过JSON,它具备许多功能,并且非常高的性能。我们的TDocVariant自定义变体类型是处理这类无模式数据的一种强大方式,但一些用户......
  • freebsd、openbsd、netbsd的区别
    开源BSD有三大系列:freebsd、openbsd、netbsd。其实MacOSX也是BSD系列,只不过是商业。1.FreeBSDFreeBSD是从386BSD的基础上发展起来的,而386BSD是由伯克利的计算机科学家BillJolitz开发的针对Intel80386芯片的一种BSD版本。因为这个原因,FreeBSD在32位体系的x86机器上总是运行......
  • delphi cxgrid 画鼠标经过的轨迹或者说是鼠标经过下高亮行
    unitUnit1;interfaceusesWindows,Messages,SysUtils,Variants,Classes,Graphics,Controls,Forms,Dialogs,dxSkinsCore,dxSkinsDefaultPainters,dxSkinscxPCPainter,cxStyles,cxCustomData,cxGraphics,cxFilter,cxData,cxDataStorage,cxEdit,......
  • delphi cxgrid自定义画焦点框,把自带的虚线框去掉
    参考资料将FocusRect从虚线更改为实线或更改FocusRect的颜色|DevExpress支持如何在TableView网格中的整个选定/聚焦行周围绘制边框?|DevExpress支持 procedureTcxGridTableView.DoCustomDrawCell(ACanvas:TcxCanvas;AViewInfo:TcxGridTableDataCellViewInfo;v......
  • delphi cxgrid 自定义画焦点框
    procedureTMyTable.MyBandedTableViewCustomDrawCell(Sender:TcxCustomGridTableView;ACanvas:TcxCanvas;AViewInfo:TcxGridTableDataCellViewInfo;varADone:Boolean);varbounds:TRect;beginifAViewInfo.Focusedthenbeginbounds:=A......
  • delphi安卓动态权限申请
    delphi安卓动态权限申请安卓8及以上版本,除了原来的静态权限申请以外,还需要动态权限申请。delphi10.3开始支持安卓动态权限申请。delphi11开始官方改变了安卓动态权限申请的参数类型,导致原来编写的代码,编码报错。下面的代码,可以很好地解决权限问题。兼顾了delphi10.3和delphi11......
  • lazarus交叉编译
    lazarus交叉编译虽然lazarus可以安装在windows,linux,macos。。操作系统上面,但是交叉编译有其独到的方便之处,比如,可以在windows上用lazarus编译所有OS平台的程序。1)下载并编译fpcupdeluxe下载地址:https://github.com/LongDirtyAnimAlf/fpcupdeluxe.git下载完成,用lazarus编译好......