Solved

Delphi3 compiler options

Posted on 2001-06-21
10
415 Views
Last Modified: 2010-04-06
I looked at part of my compiled application and found that it was not fully compiled.
Instead of an .exe consisting of only machine code there are bits of text of object parameters, procedure names, etc.
My guess is that instead of generating machine code for some objects it is just imbedding them as they are and jumping to them when required. It looks more like interpreted code instead of compiled code.
I've looked at 'all' the compiler options but I can't find anything that would produce this effect.
I suppose there's a 'fast compile' option that does this and then a 'full compile' option to produce the final code.
Can you please tell me which option(s) I need to set to produce fully compiled machine code.


0
Comment
Question by:frog
  • 3
  • 2
  • 2
  • +3
10 Comments
 

Accepted Solution

by:
Micke_Holm earned 50 total points
ID: 6213503
Hi frog,

There is no such switch as Delphi compiles to natvive machine code.

What you saw was the resources for forms and data modules. Delphi puts them in a special format as a ordinary Win32 resource. It uses that information to create the forms and data modules in run time.

//Micke
0
 
LVL 5

Expert Comment

by:TheNeil
ID: 6213516
Huh? Delphi doesn't produce interpreted code. If you look at any Delphi EXE you'll find chunks of text that appear familiar but the file is fully compiled (don't worry). Just in case, here are the settings that I use (and as I haven't changed them they're the Delphi defaults):

Compiler (the following are on, the rest are off):
Optimisation
Aligned Record Fields
I/O errors
Debug Info
Local Symbols
Reference info
Definitions Only
Assertions
Show Hints
Show Warnings
Strict var-strings
Extended Syntax
Open parameters
Huge strings
Assignable typed constants

Linker:
Map file - OFF
Linker Output - Generate DCU's

Hope that's what you needed

The Neil =:)
0
 
LVL 17

Expert Comment

by:inthe
ID: 6214050
hi,
im wondering what you were expecting it to be ?
if you look at any exe with a hex editor you'll see strings ..dont worry it is very normal.
when you compile it doesnt turn abc into 110011 or xzy it just compiles to machine readable code.this is why you would never hardcode passwords/serial numbers etc into applications and pretty much why encryption is used as with encryption you can turn abc into zxy.

Regards Barry
0
 

Author Comment

by:frog
ID: 6214378
Thanks for your comments.

Inthe, I was expecting to see the text for messageDlgs etc as text, but that was all.
I expected the rest to contain a contiguous stream of hex code that the processor would process. ( Stuff like 7E FE 61 DA  that would cause the processor to load accumulator A from HL compare it with character 'a' etc, etc.)
I didn't expect to see anything that would give any visual clues as to what the code was doing. And I certainly did not expect to see text reference to say a button, but just the hex code to create the button, ie a heap of instructions to load accumulators, shift, compare etc, etc to finally draw the button.

I reckon Micke has answered my question by saying that Delphi uses resources embedded inside the 'compiled'  .exe  "to create the forms and data modules in run time."
Just why it would create them at run time and not at compile time only adds more questions. It must be awfully slow to create objects on the fly at run time, but I suppose it gives some flexibility.
This reminds me of a question that's been on my mind for a while - why don't the Delphi handbooks and help screens give the number of machine cycles for each instruction. I've only seen references like "inc(a) is faster than a := a+1"  but there's no reference to how much faster, like "inc(a) = 4 machine cycles, a := a+1 = 27 cycles".

It sounds like it's all to do with Windows,  is it that my exe isn't actually run directly by the processor, but that it tells Windows to draw a form and Windows then gets the processor to run code within Windows to draw it?
0
 

Author Comment

by:frog
ID: 6214399
Thanks for your comments.

Inthe, I was expecting to see the text for messageDlgs etc as text, but that was all.
I expected the rest to contain a contiguous stream of hex code that the processor would process. ( Stuff like 7E FE 61 DA  that would cause the processor to load accumulator A from HL compare it with character 'a' etc, etc.)
I didn't expect to see anything that would give any visual clues as to what the code was doing. And I certainly did not expect to see text reference to say a button, but just the hex code to create the button, ie a heap of instructions to load accumulators, shift, compare etc, etc to finally draw the button.

I reckon Micke has answered my question by saying that Delphi uses resources embedded inside the 'compiled'  .exe  "to create the forms and data modules in run time."
Just why it would create them at run time and not at compile time only adds more questions. It must be awfully slow to create objects on the fly at run time, but I suppose it gives some flexibility.
This reminds me of a question that's been on my mind for a while - why don't the Delphi handbooks and help screens give the number of machine cycles for each instruction. I've only seen references like "inc(a) is faster than a := a+1"  but there's no reference to how much faster, like "inc(a) = 4 machine cycles, a := a+1 = 27 cycles".

It sounds like it's all to do with Windows,  is it that my exe isn't actually run directly by the processor, but that it tells Windows to draw a form and Windows then gets the processor to run code within Windows to draw it?
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 5

Expert Comment

by:Gwena
ID: 6217179
If you want your exe files to be inscrutable then get yourself one of the many free exe encryptors... they usually install a small asm program near the start of your exe and when your exe runs this decrypts the bytes of the exe before they are placed into memory.... you could compress the exe first and then encrypt it... that ought to make it look strange and plain-text free to snoopers with a hex editor :-)
0
 
LVL 8

Expert Comment

by:TOndrej
ID: 6217440
> It must be awfully slow to create objects on the fly at run time

I don't think so but it can be tested very easily, by creating a form with some components at designtime and then another at runtime in code, and comparing the times they take to create.

If you're worried about using the .dfm resources, don't use them.

GExperts www.gexperts.org even have a wizard called 'Components to Code' which will allow you to design a form and then generate the corresponding code for selected components.

> why don't the Delphi handbooks and
help screens give the number of machine cycles for each instruction

Try View\Debug Windows\CPU menu during debugging ;-)
0
 
LVL 8

Expert Comment

by:TOndrej
ID: 6217444
Oops, for Delphi 3 you need to add a registry entry to enable the CPU View:

http://delphi.about.com/compute/delphi/library/howto/htcpuview.htm
0
 

Author Comment

by:frog
ID: 6217671
Thanks to everyone.
You have all been helpful, so I'll accept the first comment as the answer and then post points for the rest.

0
 
LVL 17

Expert Comment

by:inthe
ID: 6220517
just to note
>>is it that my exe isn't actually run directly by the processor

exactly otherwise we could run our applications irrespective of operating stsyem..delphi is compileing our app to a win32 pe format exe which is i suppose you could say controlled by the windows os..
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Introduction The parallel port is a very commonly known port, it was widely used to connect a printer to the PC, if you look at the back of your computer, for those who don't have newer computers, there will be a port with 25 pins and a small print…
Introduction Raise your hands if you were as upset with FireMonkey as I was when I discovered that there was no TListview.  I use TListView in almost all of my applications I've written, and I was not going to compromise by resorting to TStringGrid…
When you create an app prototype with Adobe XD, you can insert system screens -- sharing or Control Center, for example -- with just a few clicks. This video shows you how. You can take the full course on Experts Exchange at http://bit.ly/XDcourse.
This is a video that shows how the OnPage alerts system integrates into ConnectWise, how a trigger is set, how a page is sent via the trigger, and how the SENT, DELIVERED, READ & REPLIED receipts get entered into the internal tab of the ConnectWise …

937 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now