13

If I have some .dcu files; how can I find out which Delphi version they were compiled with?

I received some old source code, and some .dcu files are included, and I don't have access to the original source code. I want to refactor this library out, but for that I want to just make it compile in the original Delphi version first.


By the way, the compiler could be a bit more helpful here. It states that file X was compiled with a "different" version, without saying -which- version that is....

Wouter van Nifterick
  • 23,603
  • 7
  • 78
  • 122
  • can you give complete compiler error message? – Igor Feb 20 '15 at 03:00
  • @Igor, [F2051 Unit %s was compiled with a different version of %s.%s (Delphi)](http://docwiki.embarcadero.com/RADStudio/XE7/en/F2051_Unit_%25s_was_compiled_with_a_different_version_of_%25s.%25s_%28Delphi%29 "Though it's pointless to have the verbose error message in this question, IMHO ;-)") – TLama Feb 20 '15 at 08:53
  • Instead of saying "a different version", it should say something like "Delphi XE6 / Win64". Of couse the compiler cannot know newer versions, but at least it could detect that a newer or unknown version was used, and report that. – Wouter van Nifterick Feb 23 '15 at 15:12

3 Answers3

22

From unofficial sources, look at 4th byte of the .dcu

$0F = Delphi 7
$11 = Delphi 2005
$12 = Delphi 2006 or 2007
$14 = Delphi 2009
$15 = Delphi 2010
$16 = Delphi XE
$17 = Delphi XE2
$18 = Delphi XE3
$19 = Delphi XE4
$1A = Delphi XE5
$1B = Delphi XE6
$1C = Delphi XE7
$1D = Delphi XE8
$1E = Delphi 10 Seattle
$1F = Delphi 10.1 Berlin
$20 = Delphi 10.2
$21 = Delphi 10.3
$22 = Delphi 10.4

There was no change in .dcu format going from Delphi 2006 to Delphi 2007. Therefore they use the same.

Edit Jul 2, 2016 Added XE8, 10 and 10.1 to the list.

On request, also the target platform, which is found in the second byte of the .dcu. Values are of course valid only for versions that have these targets.

$03 = Win32
$23 = Win64
$04 = Osx32
$14 = iOS emulator
$76 = iOS device
$77 = Android

Let me know if you think there's an error.

dummzeuch
  • 10,975
  • 4
  • 51
  • 158
Tom Brunberg
  • 20,312
  • 8
  • 37
  • 54
  • Doesn't these values map to the [compiler version?](http://docwiki.embarcadero.com/RADStudio/en/Compiler_Versions) (divided by ten). Ie XE = 220 = $16 *10 – whosrdaddy Feb 20 '15 at 16:08
  • @whosrdaddy Yes, for the shown ones and probably some of the earlier. A Delphi 1 .dcu has 'DCU1' as the four first bytes and I don't know when they changed that practice, D2? or D3? or 4, 5, 6? – Tom Brunberg Feb 20 '15 at 16:42
  • Thanks, that's useful information. If you're interested in getting information out of a .dcu file, make sure to check out the tool that I've linked to in my answer here. It's pretty cool. – Wouter van Nifterick Feb 23 '15 at 15:23
5

While looking for the answer, I ran into an awesome online tool by Alexei Hmelnov.

It lets you upload a .dcu file, and it'll give you extremely detailed information about it.

http://geos.icc.ru:8080/scripts/WWWBinV.dll

It shows the compiler that was used, the compile time, used units, etc.

Wouter van Nifterick
  • 23,603
  • 7
  • 78
  • 122
3

The DCU file is a proprietary format developed at Borland (now Embarcadero) as the intermediate data between compiled code and the source code. It is the main reason why the Delphi compiler can generate an executable so fast. Informations about this format are intentionally scarce. Borland did not provide documentation about it, Embarcadero seems to follow the same path. There is an utility called "DeDe" that can disassemble compiled files created by old Delphi versions and bring several informations about these, including the dcu file version. It does not work for binaries produced by Delphi compilers newer than version 5, but the source code is included, maybe it could be improved.

André Murta
  • 141
  • 2
  • 9
  • (I'm not downvoting your question, just a note.) You can find info on [What is a Delphi DCU file?](http://stackoverflow.com/questions/24665856/what-is-a-delphi-dcu-file?rq=1) in a similar question, and DeDe is antiquated (Delphi 5 was released around 15 years ago), so whether it *could be improved* is highly debatable, as the .DCU format could have changed dramatically since then. – Ken White Feb 20 '15 at 05:21
  • What debate? Delphi 5 can be used to read from and write to files so it can be used to improve a program that reads a file and writes out another file. – Paul McCarthy Dec 20 '16 at 15:40