I´m using Delphi 7 and have a new unit which I would like to use in my project. I already compiled the new. When I try using this unit in my project by adding it to the uses
clause, it comes out the an error saying .dcu file not found. I also tried putting the full path of the file in the uses
clause, but that still didn't work. I have already search for the respective .dcu file and it was nowhere found. It seems it was not generated... Can anyone give a hint how to solve this? Thanks, Ana
Asked
Active
Viewed 5,433 times
2

Jerry Dodge
- 26,858
- 31
- 155
- 327

Ana
- 23
- 1
- 4
-
1Naively the answer is that you need to ensure that the .dcu file can be found in the library path. Or perhaps the search path (not sure about that). However, I'd say that you are doing it wrong in the first place. Include the .pas file in the project, or make sure it's on the search path. Why do you want to view the .dcu file as the source? – David Heffernan Jan 19 '15 at 14:52
-
I already included my .pas file in my project, under uses. Still got the same error. Have even tried to include the file name solely and the path+file name and keeps giving the same error. – Ana Jan 19 '15 at 14:57
-
Indeed, .dcu files shouldn't be used in this manner, you cannot edit them (they're already compiled). As David says, you need to add the .pas file instead. Never in my life have I needed to do anything with a .dcu file other than delete them from time to time to clean up my project files. – Jerry Dodge Jan 19 '15 at 14:57
-
I can add a .pas file to my project without problems. So, if it works for me, but not for you, then what is the problem? There must be something special that you are doing. Hard for us to guess. You gave no details. What you need to do is spend some time isolating the problem. Work out exactly what steps are required to produce the failure. – David Heffernan Jan 19 '15 at 14:58
-
I´m new at this (using Delphi). I have a new unit (my .pas file) and want to add it to my project (which I did under uses). When I compile my project it comes out the error "filename.dcu cannot be found". That´s all. If I doing somethings else wrong I don´t know. It was always working until I "made" a new unit and want to add it to my project. Thanks anyway for your comments! – Ana Jan 19 '15 at 15:05
-
When we say "add to your project" it does not just mean "add to the uses clause". You have to go to Project > Add > Pick the file (or however, I don't remember Delphi 7). But the uses clause is not going to automatically find the file. – Jerry Dodge Jan 19 '15 at 15:07
-
Ahh... Thanks Jerry! Now it´s working. That basic info was missing for me! – Ana Jan 19 '15 at 15:11
-
I went ahead and added this critical information to your question. Those sort of things cannot stay in the comments, because comments do not last forever, and may be deleted for many reasons. – Jerry Dodge Jan 19 '15 at 19:07
1 Answers
3
Delphi is not going to find your new unit by only adding it to the uses clause. You also have to add it to the actual project. There's no need to keep track of the .dcu file(s), as they're already compiled and cannot be modified. If I remember right, in Delphi 7, go to Project > Add Existing File > Pick your .pas file. Adding a unit to the uses clause presumes that the file is already included somewhere that Delphi can find.

Jerry Dodge
- 26,858
- 31
- 155
- 327