Solved

Delphi3 compiler options

Posted on 2001-06-21
10
418 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
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Free Tool: ZipGrep

ZipGrep is a utility that can list and search zip (.war, .ear, .jar, etc) archives for text patterns, without the need to extract the archive's contents.

One of a set of tools we're offering as a way to say thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
tidtcpserver connection lost handle 2 111
SUM 2 INTEGER ARRAYS INTO 1 10 111
Multi-layered image in FireMonkey 9 68
Delphi: making a BW image transparent 10 94
A lot of questions regard threads in Delphi.   One of the more specific questions is how to show progress of the thread.   Updating a progressbar from inside a thread is a mistake. A solution to this would be to send a synchronized message to the…
This article explains how to create forms/units independent of other forms/units object names in a delphi project. Have you ever created a form for user input in a Delphi project and then had the need to have that same form in a other Delphi proj…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
I've attached the XLSM Excel spreadsheet I used in the video and also text files containing the macros used below. https://filedb.experts-exchange.com/incoming/2017/03_w12/1151775/Permutations.txt https://filedb.experts-exchange.com/incoming/201…

726 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