如何不使用IDE直接编译执行这段Delphi代码?

更新于
2026-10-05 02:26:21
2阅读来源:SEO资讯
  • 内容介绍
  • 文章标签
  • 相关推荐

本文共计294个文字,预计阅读时间需要2分钟。

csharpusing System;using System.Windows.Forms;

public class TForm : Form{ private Label L;

public TForm() { L=new Label(); L.Parent=this; // Needed to have it show up on the form. L.Left=50; L.Top=50; L.Caption=This is an example; Show(); }}

据说生成一个winform:

var F : TForm; L : TLabel; begin F := TForm.Create(Application); L := TLabel.Create(F); L.Parent := F; // Needed to have it show up on the form. L.Left := 50; L.Top := 50; L.Caption := 'This is an example'; F.Show; end;

实际上它是从my previous question开始的.

如果是C程序,我可以这样运行:

> gcc foo.c -o foo.exe > foo.exe

我怎样才能在Delphi中做到这一点?

为了编译Delphi代码,您需要一个编译器. Delphi没有免费版本,所以除非你能找到旧版本,否则你必须购买Delphi. Delphi附带了一个命令行编译器,如gcc,可以在没有IDE的情况下编译程序.

Delphi 2006和win32之前:

dcc32 YourProject.dpr

Delphi 2006和之前的.Net:

dccil YourProject.dpr

Delphi 2007及之后:

msbuild YourProject.dproj

这将导致编译二进制文件,如果是EXE,您可以像以前一样运行它.

有免费的Delphi替代品,如FreePascal和他们的免费IDE Lazarus.我没有自己检查,但我很确定它也带有命令行编译器.

本文共计294个文字,预计阅读时间需要2分钟。

csharpusing System;using System.Windows.Forms;

public class TForm : Form{ private Label L;

public TForm() { L=new Label(); L.Parent=this; // Needed to have it show up on the form. L.Left=50; L.Top=50; L.Caption=This is an example; Show(); }}

据说生成一个winform:

var F : TForm; L : TLabel; begin F := TForm.Create(Application); L := TLabel.Create(F); L.Parent := F; // Needed to have it show up on the form. L.Left := 50; L.Top := 50; L.Caption := 'This is an example'; F.Show; end;

实际上它是从my previous question开始的.

如果是C程序,我可以这样运行:

> gcc foo.c -o foo.exe > foo.exe

我怎样才能在Delphi中做到这一点?

为了编译Delphi代码,您需要一个编译器. Delphi没有免费版本,所以除非你能找到旧版本,否则你必须购买Delphi. Delphi附带了一个命令行编译器,如gcc,可以在没有IDE的情况下编译程序.

Delphi 2006和win32之前:

dcc32 YourProject.dpr

Delphi 2006和之前的.Net:

dccil YourProject.dpr

Delphi 2007及之后:

msbuild YourProject.dproj

这将导致编译二进制文件,如果是EXE,您可以像以前一样运行它.

有免费的Delphi替代品,如FreePascal和他们的免费IDE Lazarus.我没有自己检查,但我很确定它也带有命令行编译器.