4

I have an application which was started in Turbo Pascal 5 and is now at Delphi 7 (the roots of the project are over 20 years old). We are attempting to move this project to Delphi XE.

There is a unit which is being compiled into the exe which should not be compiled into this project at all. I have been unable to properly trace how it is entering into the compilation.

Is there a log or some other means that I can use to see the order of the units being compiled so that I can trace down this problem?

NOTE: I have already attempted to use the ICARUS tool to accomplish the trace without success.

EDIT: I'm sure that using brute force and enough time I can solve this issue. What I'm seeking is a more elegant solution if one is available.

Hobo Joe
  • 181
  • 14
  • 2
    Move the unit to some place where the IDE cannot find it. The compiler may choke on where it is referred. – Sertac Akyuz Sep 20 '13 at 22:15
  • The question title and body do not match. Order is irrelevant. Search your code for references to the unit's name. Clearly something refers to it. The only tool you need is an editor with a search facility. – David Heffernan Sep 20 '13 at 22:21
  • See this related question, where Peganza was discussed. http://stackoverflow.com/questions/2904011/tool-that-shows-unit-dependencies-for-delphi-2010-or-delphi-7-program/2904397#2904397 – RobertFrank Sep 20 '13 at 23:12
  • @SertacAkyuz: ensuring that the unit couldn't be compiled was the first thing that I attempted. When it stops there is no way to determine the path to the offending file. – Hobo Joe Sep 23 '13 at 16:41
  • @DavidHeffernan: I can see how you came to the conclusion the the title and body do not match. But I couldn't figure out how to say what trail of units lead to this particular during compilation more succinctly. That trail does have an ordered list but simply using 'order' is not quite the flavor, I expect. A PowerGREP search leads me to numerous units in common code which is unhelpful. Approx a quarter of the units are common between a dozen different products. – Hobo Joe Sep 23 '13 at 16:48
  • @RobertFrank: I attempted the ICARUS portion of Peganza to attempt just that thing. It did not give me the picture I needed to solve the issue. – Hobo Joe Sep 23 '13 at 16:50

4 Answers4

6

To trace the order, you might try using a tool like Process Monitor to monitor disk I/O. Delphi doesn't log that kind of information itself.

To discover why the unit is being included in your program, there's an easier way, though. Simply delete (or hide) the unit. Compilation will fail, and the compiler will point at the uses clause that mentions the nonexistent unit.

Rob Kennedy
  • 161,384
  • 21
  • 275
  • 467
  • +1, except with some IDE bugs, sometimes I do this and the compiler fails to tell me which unit the problem comes from – Jerry Dodge Sep 20 '13 at 22:23
  • 1
    If I remember correct the compiler may stop on a unit which indirectly is effected but still say that that unit is missing. But I think this should resolve the issue. – Sertac Akyuz Sep 20 '13 at 22:24
  • I hadn't thought of Process Monitor. A very interesting idea that I'll look into. As for the hiding of the unit, that's the brute force method I had in mind if a more elegant solution was not available. I have edited my question to reflect more of what I had in mind. – Hobo Joe Sep 23 '13 at 17:00
  • It might be brute force, but it's also dead simple, and probably as fast as anything else. – Rob Kennedy Sep 23 '13 at 17:34
  • @RobKennedy: Indeed this may be the best way, and, in the end, the way that I chose. It only took a few hours (insidious legacy code) but I was hoping that there would be a better solution (better being less time in this case). – Hobo Joe Sep 27 '13 at 12:43
1

My answer in the question Can I determine the order in which my units have been initialized? can help here.

It will list the load order of units and it's likely that the unit before is responsible for loading it.

Community
  • 1
  • 1
Remko
  • 7,214
  • 2
  • 32
  • 52
  • 1
    I have only the tools of Delphi 7 at my disposal for this, and on initial glance, the link refers to Delphi 2010. I'm getting there but not there yet. Curious, are unit initializations always in the order of compilation? Do units without the initialization section always become members of this initialization list? – Hobo Joe Sep 23 '13 at 17:05
0

When I find such a problem in my compilations, I do the following:

  1. Inspect IDE library path. Remove unnecessary and extraneous directories.

  2. Inspect project search path. Remove unnecessary and extraneous directories.

  3. Delete ALL DCUS.

  4. Find all Windows Vista/Windows 7/Windows8 "virtualstore" content and remove, as well, find any extraneous BPL or DCP, and remove.

  5. Create a UnitAlias for the undesired unit. unit Alias "UnwantedUnit=GoAway".

  6. Build. (Always use Build, not Compile, in such situations)

This makes finding the unit that fails much easier.

Warren P
  • 65,725
  • 40
  • 181
  • 316
0

Rename all de occurences of the .pas file in your filesystem and remove all the corresponding DCU files. Then build your project. If a uses is made, the compiler will spot it.

AlexSC
  • 1,823
  • 3
  • 28
  • 54