导航:首页 > 源码编译 > delphi千年编译教程

delphi千年编译教程

发布时间:2022-05-17 14:33:30

1. Delphi写的程序怎么编译成可执行文件

方法一、在DELPHI里面选菜单PROJECT下的BUILD可以生成EXE文件。
方法二、在命令提示符下使用DCC32.EXE编译.DPR工程文件,例如:
C:\>DCC32 A.DPR

2. Delphi的命令行编译命令

Borland出品的Delphi,有着闪电般的编译速度,但是在界面控件使用较多、工程项目较大的时候,编译一个工程仍需要一段时间,打开庞大的Delphi IDE,也需要时间。其实,在一个工程开发结束,调试完成之后的Release编译,完全可以用命令行来执行,因为Delphi的编译器参数不像C++编译器那样复杂。

笔者把Delphi联机手册中关于命令行编译(command-line compiler)的几篇主题作了翻译,希望对Delphi开发人员有帮助。

目录
1. Command-line compiler
命令行编译器
2. Command-line compiler options
命令行编译器选项
3. Compiler directive options
编译器指令选项
4. Compiler mode options
编译模式选项
5. DCC32.CFG file
编译器配置文件DCC32.CFG
6. Debug options
调试选项
7. Directory options
目录选项
8. IDE command-line options
IDE命令行选项
9. Generated files
几个IDE自动生成的文件介绍

Command-line compiler
命令行编译器
Delphi's command-line compiler (dcc32.EXE) lets you invoke all the functions of the IDE compiler (DELPHI32.EXE) from the DOS command line (see IDE command-line options. Run the command-line compiler from the DOS prompt using the syntax:
Delphi’s命令行编译器(dcc32.exe)允许你从DOS命令行方式(参照:IDE命令行选项)实现IDE编译器(delphi32.exe)的所有功能。用DOS命令运行命令行编译器语法如下:
dcc32 [options] filename [options]
dcc32 [选项] [文件名] [选项]
where options are zero or more parameters that provide information to the compiler and filename is the name of the source file to compile. If you type dcc32 alone, it displays a help screen of command-line options and syntax.
零或多个参数给编译器提供信息,文件名指定需要编译的源文件名。如果你单独输入dcc32,它会显示一个关于命令行编译的选项和语法的屏幕。
If filename does not have an extension, the command-line compiler assumes .dpr, then .pas, if no .dpr is found. If the file you're compiling to doesn't have an extension, you must append a period (.) to the end of the filename.
如果文件名没有扩展名,命令行编译器会查找扩展名为.dpr的同名文件,如果找不到,则查找扩展名为.pas的同名文件。如果你的源文件确实没有扩展名,你需要在文件名的末尾添加(.)。
If the source text contained in filename is a program, the compiler creates an executable file named filename.EXE. If filename contains a library, the compiler creates a file named filename.DLL. If filename contains a package, the compiler creates a file named filename.BPL. If filename contains a unit, the compiler creates a unit file named filename.dcu.
如果指定的源文件是一个工程文件,编译器会创建一个扩展名为.EXE的同名可执行文件。如果指定的源文件是一个库文件,编译器创建一个扩展名为.DLL的同名动态链接库文件。如果指定的源文件是一个包文件,编译器会创建一个扩展名为.BPL的同名包。如果指定的源文件是一个单元文件,编译器会创建一个扩展名为.dcu的目标代码文件。
You can specify a number of options for the command-line compiler. An option consists of a slash (/) or immediately followed by an option letter. In some cases, the option letter is followed by additional information, such as a number, a symbol, or a directory name. Options can be given in any order and can come before or after the file name.
你可以为命令行编译器指定多个参数。一个参数包含一个破折号“-”(或“/”)和紧跟着的一个选项字符构成。通常情况下,选项字符后面会跟一些附加的信息,如一个数字、一个符号、一个目录等。选项可以是任意顺序并且可以在源文件名前面或后面。

Command-line compiler options
命令行编译选项
The IDE lets you set various options through the menus; the command-line compiler gives you access to these options using the slash (/) delimiter. You can also precede options with a hyphen (-) instead of a slash (/), but those options that start with a hyphen must be separated by blanks. For example, the following two command lines are equivalent and legal:
IDE允许你使用菜单来设置各种编译选项,而命令行编译器允许你使用字符“/”作为分隔符来设定这些编译选项。你也可以使用连字符“-”来代替“/”,但是用“-”引出的参数之间必须用空格隔开。例如,下面两个命令都是等同的也是合法的:
DCC -IC:\DELPHI -DDEBUG SORTNAME -$R- -$U+
DCC /IC:\DELPHI/DDEBUG SORTNAME /$R-/$U+
The first command line uses hyphens with at least one blank separating options. The second uses slashes and no separation is needed.
第一个编译命令用“-”引出参数,且参数之间有多个空格分隔。第二个编译命令用“/”引出参数,参数之间不必要分隔。
The following table lists the command-line options. In addition to the listed options, all single-letter compiler directives can be specified on the command line, as described in Compiler directive options.
下列表中列出所有的命令行参数。在附加的选项列表中,所有的单字符编译器指令都可以在命令行编译中使用,详情请参照:编译器指令。
Option Description
选项 描述
Aunit=alias 设置单元别名
B 编译所有单元
CC 编译控制台程序
CG 编译图形界面程序
Ddefines 编译条件符号定义
Epath 可执行文件输出路径
Foffset 查找运行期间错误
GD 生成完整.Map文件
GP 生成.Map文件Public段
GS 生成.Map文件Segment段
H 输出提示信息
Ipaths 文件包含路径
J 生成.Obj目标文件
JP 生成C++类型.Obj目标文件
Kaddress Set image base address
LEpath 包.BPL文件输出路径
LNpath .dcp文件输出路径
LUpackage 使用运行期间包列表
M 编译有改动的源文件
Npath dcu/dpu文件输出目录
Opaths .Obj文件(汇编目标代码文件)路径
P 按8.3格式文件名查找
Q 安静模式
Rpaths 资源文件(.RES)路径
TXext 目标文件扩展名
Upaths 单元文件路径
V 为Turbo Debugger生成调试信息文件
VN 以.Giant格式生成包含命名空间的调试信息文件(将用于C++Builder)
VR 生成调试信息文件.rsm
W 输出警告信息
Z Disable implicit compilation
$directive Compiler directives
--Help 显示编译选项的帮助。同样的,如果你在命令行单独输入dcc32,也会显示编译选项的帮助。
--version 显示产品名称和版本

Compiler directive options
编译器指令选项
Delphi supports the compiler directives described in Compiler directives. The $ and D command-line options allow you to change the default states of most compiler directives. Using $ and D on the command line is equivalent to inserting the corresponding compiler directive at the beginning of each source file compiled.
Delphi支持用编译器指令关键字描述的编译器指令。使用“$”和“D”命令行选项可以改变所有的默认编译器状态。用“$”和“D”命令行选项等同于在源文件的前面添加编译器指令。
Switch directive option
编译器指令选项开关
The $ option lets you change the default state of all of the switch directives. The syntax of a switch directive option is $ followed by the directive letter, followed by a plus (+) or a minus (-). For example:
“$”允许你改变每一种编译器指令默认状态。编译器指令的语法是“$”后紧跟一个指令字符,再跟一个“-”或“+”。例如:
dcc32 MYSTUFF -$R-
compiles MYSTUFF.pas with range-checking turned off, while:
不使用边界检查编译MYSTUFF.pas单元:
dcc32 MYSTUFF -$R+
compiles it with range checking turned on. Note that if a {$R+} or {$R-} compiler directive appears in the source text, it overrides the -$R command-line option.
使用界面检查编译MYSTUFF.pas单元。如果将编译器指令{$R+}或{$R-}添加到源文件的开始,它将覆盖从命令行传入的参数。
You can repeat the -$ option in order to specify multiple compiler directives:
你可以用多个“$”来指定多个编译器指令,如:
dcc32 MYSTUFF -$R--$I--$V--$U+
Alternately, the command-line compiler lets you write a list of directives (except for $M), separated by commas:
命令行编译器允许作用逗号分隔的编译器指定列表,如:
dcc32 MYSTUFF -$R-,I-,V-,U+
只需要用一个“$”符号。
Only one dollar sign ($) is needed.
注意,因为$M的格式不一样,你不能在逗号分隔的指令列表中使用$M
Note that, because of its format, you cannot use the $M directive in a list of directives separated by commas.
Conditional defines option
条件编译选项
The -D option lets you define conditional symbols, corresponding to the {$DEFINE symbol} compiler directive. The -D option must be followed by one or more conditional symbols separated by semicolons (;). For example, the following command line:
“-D”选项允许你定义一个编译条件,符合你用{$DEFINE symbol}定义的编译器指令。“-D”选项后必须跟随一或多个用分号分隔的编译条件符号,如下命令:
dcc32 MYSTUFF -DIOCHECK;DEBUG;LIST
defines three conditional symbols, iocheck, debug, and list, for the compilation of MYSTUFF.pas. This is equivalent to inserting:
定义了三个编译条件符号:IOCHECK,DEBUG,LIST,用于MYSTUFF.pas单元中。这等同于在源文件中插入以下语句:
{$DEFINE IOCHECK}
{$DEFINE DEBUG}
{$DEFINE LIST}
at the beginning of MYSTUFF.pas. If you specify multiple -D directives, you can concatenate the symbol lists. Therefore:
如果你指定了多个“-D”选项,你可以联接它们,如下:
dcc32 MYSTUFF -DIOCHECK-DDEBUG-DLIST

is equivalent to the first example.
等同于第一个例子。

Compiler mode options
编译模式选项
A few options affect how the compiler itself functions. As with the other options, you can use these with either the hyphen or the slash format. Remember to separate the options with at least one blank.
有几个选项能影响编译器自身的功能。像其它选项一个,你可以使用“/”或“-”的格式。别忘了用至少一个空格分隔这些选项。
Make (-M) option
选项(-M)
The command-line compiler has built-in MAKE logic to aid in project maintenance. The -M option instructs command-line compiler to check all units upon which the file being compiled depends. Using this option results in a much quicker compile time.
命令行编译器使用构造逻辑的方式来维护工程。“-M”选项指示编译器检查所有与编译文件相关联的文件。用这个参数会导致编译时间增大。
A unit is recompiled under the following conditions:
一个源文件在下列情况下会重新编译:
The source file for that unit has been modified since the unit file was created.
源文件被创建以来被修改过;
用“$I”指令包含的任何文件,用“$L”包含的任何.Obj文件,或用“$R”关联的任何资源文件.Res,比源文件中的要新;
Any file included with the $I directive, any .OBJ file linked in by the $L directive, or any .res file referenced by the $R directive, is newer than the unit file.
The interface section of a unit referenced in a uses statement has changed.
单元接口部分interface的uses段有改动。
Units compiled with the -Z option are excluded from the make logic.
在单元编译时指令“-Z”在构造逻辑期不被接受。
If you were applying this option to the previous example, the command would be:
如果你在上一个例子中使用这个指令,编译命令就应该是:
dcc32 MYSTUFF -M
Build all (-B) option
编译所有 选项(-B)
Instead of relying on the -M option to determine what needs to be updated, you can tell command-line compiler to update all units upon which your program depends using the -B option. You can't use -M and -B at the same time. The -B option is slower than the -M option and is usually unnecessary.
用于取代要知道哪些单元需要更新-M的选项,你可以使用-B选项来更新所有你的程序中关联的单元。你不能在程序中同时使用-M和-B。选项-B比-M速度更慢,而且它并不是必需的。
If you were using this option in the previous example, the command would be
如果你在前一个例子中使用这个参数,编译命令就应该是:
dcc32 MYSTUFF -B
Find error (-F) option
查找错误 选项(-F)
When a program terminates e to a runtime error, it displays an error code and the address at which the error occurred. By specifying that address in a -Faddress option, you can locate the statement in the source text that caused the error, provided your program and units were compiled with debug information enabled (via the $D compiler directive).
当一个程序由于运行期间错误而终止时,它会显示一个错误号和错误地址在错误发生时。用-Faddress选项来指定错误地址,你在源文件中能找到引发错误的位置,如果你的程序和单元编译时附加了调试信息(使用$D编译器指令)。
In order for the command-line compiler to find the runtime error with -F, you must compile the program with all the same command-line parameters you used the first time you compiled it.
为了命令行编译器能用-F选项查找运行期间错误,你必须传递与第一次编译时相同的指令列表。
As mentioned previously, you must compile your program and units with debug information enabled for the command-line compiler to be able to find runtime errors. By default, all programs and units are compiled with debug information enabled, but if you turn it off, using a {$D-} compiler directive or a -$D- option, the command-line compiler will not be able to locate runtime errors.
先前提到过,你的程序和单元必须启用调试信息,命令行编译器才能查找运行期间错误。默认情况下,所有的程序和单都是启用调试信息的,除非你用{-D}或-$D-指令关闭它,这样,命令行编译器就不能查找运行期间错误了。
Use packages (-LU) option
使用包(-LU)选项
Use the -LU option to list additional runtime packages that you want to use in the application being compiled. Runtime packages already listed in the Project Options dialog box need not be repeated on the command line.
使用-LU选项来在编译时添加你应用程序中要用到的运行期间包。运行期间包已经在“工程选项”对话框中列举的,不必再在命令行中添加。
Disable implicit compilation (-Z) option
(此选项在delphi6.0/7.0中有不同描述,在此不作翻译)
The -Z option prevents packages and units from being implicitly recompiled later. With packages, it is equivalent to placing {$ IMPLICITBUILD OFF} in the .dpk file. Use -Z when compiling packages that provide low-level functionality, that change infrequently between builds, or whose source code will not be distributed.
Target file extension (-TX) option
目标文件扩展名(-TX)选项
The -TX option lets you override the default extension for the output file. For example,
选项-TX允许你改写默认的输出文件扩展名。例如:
dcc32 MYSTUFF -TXSYS
generates compiled output in a file called MYSTUFF.SYS.
生成的将是一个叫做MYSTUFF.SYS的文件。
Quiet (-Q) option
安静模式(-Q)选项
The quiet mode option suppresses the printing of file names and line numbers ring compilation. When the command-line compiler is invoked with the quiet mode option
安静模式选项禁止在编译时显示文件名及代码行数,如果命令行编译器调用这个选项的话。
dcc32 MYSTUFF -Q its output is limited to the startup right message and the usual statistics at the end of compilation. If any errors occur, they will be reported.

它的输出仅限于起始时行版权信息以及结尾的统计信息。当然,如果发生错误,它也会输出。

DCC32.CFG file
DCC32.CFG配置文件
You can set up a list of options in a configuration file called DCC32.CFG, which will then be used in addition to the options entered on the command line. Each line in configuration file corresponds to an extra command-line argument inserted before the actual command-line arguments. Thus, by creating a configuration file, you can change the default setting of any command-line option.
你可以设置一个编译选项列表到一个叫做DCC32.CFG的配置文件中,它将用于编译时附加到命令行参数后。配置文件的每一行都相当于一个额外的命令行参数插入到实际的命令行参数前(注意,是实际参数前)。因而,你可以使用这个配置文件改变一些命令行参数的默认设置。
The command-line compiler lets you enter the same command-line option several times, ignoring all but the last occurrence. This way, even though you've changed some settings with a configuration file, you can still override them on the command line.
命令行编译器允许你输入相同的命令行参数,它将忽略所有除最后一个之外。这个的话,尽管通过配置文件你可以改变一些设置,你仍然可以覆盖它使用命令行参数。
When dcc32 starts, it looks for DCC32.CFG in the current directory. If the file isn't found there, dcc32 looks in the directory where DCC32.EXE resides.
当dcc32启动时,它查找DCC32.CFG文件在当前目录。如果文件没有找到,dcc32会查找它所在的目录。
Here's an example DCC32.CFG file, defining some default directories for include, object, and unit files, and changing the default states of the $O and $R compiler directives:
以下是一个DCC32.CFG配置文件的例子,定义了关于文件包含、OBJ文件包含、单元文件搜索路径信息,并改变了编译器指令$O和$R的默认值。
-IC:\DELPHI\INC;C:\DELPHI\SRC
-OC:\DELPHI\ASM
-UC:\DELPHI\UNITS
-$R+
-$O-
Now, if you type:
现在,如果你输入:
dcc32 MYSTUFF
the compiler performs as if you had typed the following:
编译器把它当作你输入如下命令:
dcc32 -IC:\DELPHI\INC;C:\DELPHI\SRC -OC:\DELPHI\ASM -UC:\DELPHI\UNITS -$R+ -$O- MYSTUFF

Debug options
调试选项
The compiler has two sets of command-line options that enable you to generate external debugging information: the map file options and the debug info options.
编译器有两个命令行参数可以生成外部调试信息:MAP文件选项和调试信息选项。
Map file (-G) options
Map文件(-G)选项
The -G option instructs the command-line compiler to generate a .map file that shows the layout of the executable file. Unlike the binary format of executable and .dcu files, a .map file is a legible text file that can be output on a printer or loaded into the editor. The -G option must be followed by the letter S, P, or D to indicate the desired level of information in the .map file. A .MAP file is divided into three sections:
选项-G指示命令行编译器生成一个.map文件来查看一个可执行文件的布局。不同于可二进制的可执行文件和.dcu文件,.map文件是一个可读的文本文件,可以被打印或是其它文本编辑器编辑。选项-G后必须跟字符S、P或D,去决定你想要在.map文件列出的信息。一个.MAP文件被分成三个节:
Segment
Publics
Line Numbers
-GS outputs only the Segment section, -GP outputs the Segment and Publics section, and -GD outputs all three sections. -GD also generates a .DRC file that contains tables of all string constants declared using the resourcestring keyword.
-GS选项只输出Segment Section,-GS选项输出Segment和Publics,-GD输出所有的三个Sections.-GD选项也生成一个扩展名为.DRC的文件包含所有的用resourcestring关键字声明的字符串常量。
For moles (program and units) compiled in the {$D+,L+} state (the default), the Publics section shows all global variables, proceres, and functions, and the Line Numbers section shows line numbers for all proceres and functions in the mole. In the {$D+,L-} state, only symbols defined in a unit's interface part are listed in the Publics section. For moles compiled in the {$D-} state, there are no entries in the Line Numbers section.
用默认的编译选项{$D+,L+}编译模块(程序或单元),Publics Section列举所有的全局变量、过程和函数,Line Numbers Section列举模块中所有的过程和函数的行号。如果用{$D+,L-}编译选项编译模块,Publics Section中仅列举在单元的interface部分定义的符号。如果用{$D-}选项编译模块,在Line Numbers Section没有任何入口。
Debug info (-V) options
调度选项(-V)
The -V options (-V, -VN. and -VR), which cause the compiler to generate debug information, can be combined on the command line.
选项-V、-VN、-VR会指示编译器生成调试信息,它们能在命令行中组合使用。
Generate Turbo Debugger debug info (-V) option
生成Turbo Debugger使用的调试信息的选项(-V)
When you specify the -V option on the command line, the compiler appends Turbo Debugger 5.0-compatible external debug information at the end of the executable file. Turbo Debugger includes both source- and machine-level debugging and powerful breakpoints.
当你在命令行中使用-V选项时,编译器会在可执行文件的末尾附加与Turbo Debugger5.0一致的外部调试信息。Turbo Debugger包含代码和硬件级别的强大的断点。
Even though the debug information generated by -V makes the resulting executable file larger, it does not affect the actual code in the executable, and does not require additional memory to run the program.
虽然附加调试信息到查执行文件中会使可执行文件增大,但是它并不影响实际可执行文件中的可执行代码,也不需要额外的内存来启动程序。
The extent of debug information appended to the executable file depends on the setting of the $D and $L compiler directives in each of the moles (program and units) that make up the application. For moles compiled in the {$D+,L+} state, which is the default, all constant, variable, type, procere, and function symbols are known to the debugger. In the {$D+,L-} state, only symbols defined in a unit's interface section are known to the debugger. In the {$D-} state, no line-number records are generated, so the debugger cannot display source lines whe

3. delphi 如何编译生成exe

F9,运行后关闭,工程所在目录下即有了一个可执行文件
或者如楼上所说CTRL+F9
或者
菜单/project/Build

4. delphi怎样编写服务程序

Windows NT服务程序不同于一般的运行程序,它不需要NT登录进去,只需要开机进入NT系统便可以运行,一般用于系统服务方面的应用,学会编写NT服务程序对网络管理人员而言是非常重要的,Delphi作为一种高效、快速、强大的开发语言,为开发NT服务程序提供了非常便捷的方法,加上其可视化界面以及与数据库的完美结合,使我们开发与数据库有关的NT服务程序变得非常简单,下面以编写一个NT定期备份程序为例,介绍如何运用Delphi编写Windows NT的服务程序。
打开Delphi编辑器,选择菜单中的File|New,在New Item中选择Service Application项,Delphi便自动为你建立一个基于TServiceApplication的新工程,TServiceApplication是一个封装NT服务程序的类,它包含一个TService1对象以及服务程序的装卸、注册、取消方法。
将TService1对象的属性做下列更改:
DisplayName与Name改为:DataBackup,ServiceStartName属性改为系统管理员用户(如DOMAIN\Administrator)和Password则输入用户密码
这样,服务程序运行时将自己以该用户的权限操作NT。
这样,一个NT服务程序编写已经完成,在Delphi编辑器中选择菜单Run|Parameters,在Parameters中输入/install,程序编译运行后,一个名为DataBackup的NT服务程序已经安装好,你可以双击控制面板中的服务项目,将会看到此服务程序,只是此服务程序没有任何东西而已;在Delphi编辑器中选择菜单Run|Parameters,在Parameters中输入/uninstall,程序编译运行后,系统将会将此服务程序卸掉。
服务程序是通过控制一个线程的生成、暂停、继续、停止来达到服务目的的,因此我们必须加入一个TSession对象来编写文件自动备份代码,在Delphi编辑器中选择菜单中的File|New,在New Item中选择Thread Object项,Delphi会提示你为该TSession对象输入一个名称(输入DataCopy),Delphi便生成了一个基于TSession的DataCopy对象,并提供了一个Execute过程供重载,我们要Execute过程中输入以下程序:
var
Hour, Min, Sec, MSec: Word;
TimeStamp, DirectoryEdit1, DirectoryEdit2: String;
SearchRec: TSearchRec;
Source, Temp, Dest: Pchar;
F, F1: THandle;
FF, FF1: WIN32_FIND_DATA;
Begin

// 每次文件备份执行时间
TimeStamp:= '12:00';

// 文件备份源目录
DirectoryEdit1:= 'C:\temp';

// 文件备份目录
DirectoryEdit2:= 'C:\temp1';
While True do
Begin
DecodeTime(Time, Hour, Min, Sec, MSec);
IF Trim(TimeStamp) = Format('%-2.2d:%-2.2d',[Hour, Min]) then
Begin
GetMem(Source, 250);
GetMem(Dest, 250);
GetMem(Temp, 250);
StrP(Dest, DirectoryEdit2 + '\' + FormatDateTime('YYYYMMDD', Date));
CreateDirectory(Dest, Nil);
IF FindFirst(DirectoryEdit1 + '\*.*', faAnyFile, SearchRec) = 0 then
Begin
Repeat
StrP(Source, DirectoryEdit1 + '\' + SearchRec.Name);
StrP(Dest, DirectoryEdit2+'\' + FormatDateTime('YYYYMMDD', Date) + '\' + SearchRec.Name);
CopyFile(Source, Dest, False);
Until FindNext(SearchRec) <> 0;
end;
SysUtils.FindClose(SearchRec);
FindClose(F);
FreeMem(Source, 250);
FreeMem(Dest, 250);
FreeMem(Temp, 250);
end;
Sleep(60000);
end;
end;
此线程执行时每隔一分钟将检查一次时间,看是否到了备份时间,如果是则将DirectoryEdit1中的所有文件拷到DirectoryEdit2目录中去。
现在编写服务控制DataCopy线程的代码,在TdataBackup对象中的OnStart、OnStop、OnPause、OnContinue事件中分别输入如下代码:
Procere TDataBackup.DataBackupStart(Sender: TService;
var Started: Boolean);
begin
DataThread:= TDataCopy.Create(False);
Started := True;
end;

procere TDataBackup.DataBackupStop(Sender: TService;
var Stopped: Boolean);
begin
DataThread.Terminate;
Stopped := True;
end;

procere TDataBackup.DataBackupPause(Sender: TService;
var Paused: Boolean);
begin
DataThread.Suspend;
Paused := True;
end;

procere TDataBackup.DataBackupContinue(Sender: TService;
var Continued: Boolean);
begin
DataThread.Resume;
Continued := True;
end;
这样一个文件自动备份程序已经完成,编译好后,加上/install参数执行程序,系统会将此服务程序安装,由于服务程序中StartType属性为stAuto,NT每次启动时,此程序自动执行,你可以在控制面板中的服务项目来启动、暂停、恢复、停止它,也可以加上/uninstall参数执行程序来卸掉它。通过上述例子我们可以看到,用Delphi编写NT服务器程序十分方便,而且你也可以在TService对象上加许多非可视化控件来与数据库关联,实现很多复杂的功能。

5. 如何使用delphi 编译rtklib

1. 首先在vs2013中新建一个win32的dll项目

2. 在项目上添加一个文件夹[rtklibsrc]然后在文件夹上【添加现有项目】把rtklib的源文件加入工程。在rtklibsrc下建立rcv把rcv下面的文件也添加到工程

3. 现在开始编译工程,你会发现很多错误。下面我们一步步来解决错误。

1> Q: error C1853:
“Debug\rtklibHelper.pch”预编译头文件来自编译器的早期版本,或者预编译头为 C++ 而在 C 中使用它(或相反)
x:\xxxx\rtklibhelper\rtklibsrc\tle.c 1 1 rtklibHelper
A: 不使用预编译头

2> Q: 错误 1 error C4996: 'strncpy': This function or
variable may be unsafe. Consider using strncpy_s instead. To disable
deprecation, use _CRT_SECURE_NO_WARNINGS. See online help for
details. x:\xxxx\rtklibhelper\rtklibhelper\rtklibsrc\tle.c

A: 其实提示上面已经告诉你方法了,需要你加入预编译指令来取消这个错误[_CRT_SECURE_NO_WARNINGS]

3> Q: error C4996: 'gethostbyname': Use getaddrinfo() or
GetAddrInfoW() instead or define _WINSOCK_DEPRECATED_NO_WARNINGS to
disable deprecated API warnings
x:\xxxx\rtklibhelper\rtklibsrc\stream.c

A: 这个错误和上面类似,加入[_WINSOCK_DEPRECATED_NO_WARNINGS ]

4> Q:接下来是一个这样的错误 error C2466: 不能分配常量大小为 0 的数组 x:\xxxx\rtklibhelper\rtklibsrc\rinex.c

A:这个错误我们来看一下, 在[MAXPRNGLO]上面按F12,看他的定义处

这个常量为0,那么不能进行编译,我们想上面一样在预编译器里面加入 ENAGLO

5> Q: error C1083: 无法打开包括文件: “rtklib.h”: No such file or
directory x:\xxxx\rtklibhelper\rtklibsrc\rcv\ublox.c 41 1
rtklibHelper

A: 添加附加目录设置[.\rtklibsrc] , 注意是C/C++的常规下面,不是链接器的常规页面。

6> Q: error LNK2005: _input_oem3 已经在 novatel.obj 中定义 x:\xxxx\rtklibhelper\novatel_old.obj rtklibHelper

A: 这个错误是添加文件的时候添加重复了novatel_old.c不应该添加了,删除即可

7>: Q: error LNK2019: 无法解析的外部符号 _settspan,该符号在函数 _postpos 中被引用 x:\xxxx\rtklibhelper\postpos.obj rtklibHelper

error LNK2019: 无法解析的外部符号 __imp__timeGetTime@0,该符号在函数
_tickget 中被引用 x:\xxxx\rtklibhelper\rtkcmn.obj rtklibHelper

error LNK2019: 无法解析的外部符号 __imp__accept@12,该符号在函数
_accept_nb 中被引用 x:\xxxx\rtklibhelper\stream.obj rtklibHelper

A: 添加附加库[连接器->输入->附加依赖库]添加winmm.lib, ws2_32.lib

8>:Q: error LNK2019: 无法解析的外部符号 _showmsg,该符号在函数 _convrnx 中被引用 x:\xxxx\rtklibhelper\convrnx.obj rtklibHelper

A: 一查showmsg这个函数如果在DLL中需要自己定义,rtklib里面已经做好了处理需要在预处理器里面加入[DLL]即可。

预处理器里面我们添加了

_CRT_SECURE_NO_WARNINGS
_WINSOCK_DEPRECATED_NO_WARNINGS
ENAGLO
DLL

最后rtklibHelper编译成功了,可以开始编写具体的功能函数了。

6. delphi编译完的文件,怎么生产exe可执行文件。希望能给写出具体过程或者教程也行。

点击左上方的RUN按钮即可试运行程序并在默认目录下生成可执行文件

7. delphi应该怎么学从何学起

建议按照下面步骤吧....
先声明下
delphi
在WIN32应用方面
MIS数据库方面,C/S多层,,很强大,,,呵呵......
1:
先学
Pascal
,
Object
Pascal.
只要学习pascal的语法就行,比如变量声明,各种操作符,关键字等.
不管那种语言的语句基本上都有三种:
顺序语句,条件语句,循环语句.
2:然后学delphi的IDE开发环境,(这个就是指你所言的编译工具使用方法)
因为现在pascle的环境很难找了,也不好用,都是dos下的东东,所以上面第一点下面的基础学明白了,就可以打开delphi的IDE环境下练手了,,
初期可以编一些简单的小东西,增加自己的信心:
比如说计算器啦等等.呵呵,我觉得编个计算机可以很快的熟悉pascal的基本语法和delphi
IDE的基本控件.
3:
下面就是要熟悉delphi
IDE下各种常用的控件:
按钮,输入框,下拉框,时间选择框,对话框,以及他们的各个属性,事件等.
delphi
是采用事件驱动的,
一定要了解各个控件的"事件"...
4:
进阶阶段,可以找些delphi连接数据库的例子,
了解delphi

ADO组件.
同时还要了解一般数据库的特性,比如Access,sqlserver,mysql,以至于oracle等..
5:
在往上,,网络编程,三层,自己开发组件玩...好多东西哦..

8. DELPHI源码如何编译为可执行文件

Ctrl+F9,然后你一定要看下是不是有错误,如果有错误就生成不了exe!!!!然后在进一步调试可以继续提问,希望我的回答令您满意!

阅读全文

与delphi千年编译教程相关的资料

热点内容
光遇安卓怎么转ios教程小米 浏览:959
python儿童 浏览:42
程序员毕业半年后被辞退 浏览:641
开发板系统编译 浏览:390
pdf安装包下载 浏览:48
如何配置foxmail邮箱服务器 浏览:971
python解释器编译器源代码 浏览:113
服务器ip地址正确为什么连不上 浏览:81
飞天开放平台编程指南 浏览:114
文件夹向上一级 浏览:878
apachelinux配置域名 浏览:786
王者荣耀体验服服务器出错是什么意思 浏览:824
程序员对联意思 浏览:550
php追加txt 浏览:519
java验证码jsp 浏览:753
色铅笔画动漫pdf 浏览:260
a文件编译so 浏览:347
单片机power怎么改成接地 浏览:219
https是什么app 浏览:371
androidstudio优化设置 浏览:436