IDE expecting file to be in different location - delphi

I have a component package in Delphi XE2 version 16.0.4429.46931, both a run-time and design-time package together. This package has existed for over a year, and the file/folder structure has always been the same. I keep all the units in a dedicated Source folder from the root, and the actual packages in a Packages folder in the same root. So the packages are found in \Root\Packages\ and units are found in \Root\Source\.
Today, after building the run-time package, I was going through the hints and warnings. One of the warnings was this:
[DCC Warning] Inno.TimeChart.pas(1): W1025 Unsupported language feature: 'class constructor'
The warning its self is not what worries me. The problem is when I double-click this warning, I get an error message from the IDE:
The one thing which I immediately noticed was that it is not looking in the Source folder, but rather directly in the Packages folder. Somehow, the IDE is expecting that the unit be in the same location as the package. Ever since I created the package over a year ago, I have never changed any of the library paths, locations of files, or structure of the package.
The file does exist, but in a different place than it appears to be looking. The file has never been saved in the folder with the projects, and in fact nothing other than the package projects themselves have ever been saved in the Packages folder. This all resides in the Source folder, but the IDE seems to think otherwise.
Why would the IDE think this file is in a different folder? All the other hints and warnings related to the same unit work just fine when I double-click them, but not this one.
EDIT
I've created a new test package to troubleshoot this issue.
Root\TestPackage.dpr
Root\Source\TestPackageUnit.pas
The specific piece of code which is causing this compiler warning is in this class:
type
TMyComponent = class(TComponent)
strict private
class constructor Create;
end;
When I compile, using Process Monitor, I see the IDE is searching in 30+ different places for this file (of course failing), it looks like it's searching in every library path, rather than in the one place the package says it's at.
Things I've Tried
Verified there is no difference between these paths between the DPR and DPROJ files
Installed all the latest updates and the IDE FixPack (actually gave me new problems)
Monitored file's access with Process Monitor
Filters: process name equals BDS.exe; Path ends with TestPackageUnit.pas
Result: "NAME NOT FOUND" --> Desired Access: Generic Read Disposition: Open Options: Synchronous IO Non-Alert, Non-Directory File Attributes: N ShareMode: Read, Write AllocationSize: n/a
Tried with designtime-only, runtime-only, and designtime/runtime combined
Tried with component registered and unregistered
Tried with directory in library path and not in library path
Removed about 20 unnecessary entries from library path to make it shorter
Moved directory to top of library path
Verified there is no DOF file associated with project (That I think is from older versions)
Restarted IDE and computer number of times
Cleaned up compiled and temporary files from project, including BPL and DCU files
Changed strict private to just private and even public

I do run into such problems when the delphi search path list is too long. I could always help myself in moving the relevant directories more to the front, i.e. up in the list.

Check that the file has not been added to the project file (dpr or dpk). Project - View Source will display the file.
If this isn't the case, try searching all the files in your project for the file name and see what turns up.

Found this on another website:
There is another QC that is probably linked to your problem.
http://qc.embarcadero.com/wc/qcmain.aspx?d=87693
Go to Project Options -> Delphi Compiler -> Output C/C++ and under
C/C++ output file generation select Generate DCUs only.
Dalija Prasnikar
Source: http://codeverge.com/embarcadero.delphi.general

Related

dxGDIPlusClasses.pas not found error delphi 10

When I tried to compile one of my BPL files, I get an error:
dxGDIPlusClasses.pas not found.
I double checked the unit file exists on the hard drive.
I also added $(BDSCOMMONDIR)\Dcp to the DCP Output directory, and $(BDSCOMMONDIR)\Bpl to the Package Output directory. The runtime package containing the unit was also added to the BPL.
I searched online for answers, foound one suggestion to enable Build with runtime packages under the Project Options, but when I checked I dont have that option.
Does anyone know how to solve this?
The error message indicates that either:
the compiler can't find the source file it needs for the unit.
the compiler found a .dcu file compiled with a different version of the compiler and needs to recompile it.
.dcu files are not compatible across compiler versions (with the single exception of D2006->D2007), meaning that every new version release of the compiler means all your source needs to be recompiled in order to be compatible with it.
You need to add the path to the source to Project->Options->Directories and Conditionals->Search Path so it can find the source code it needs.

Delphi .PAS code reverts to the previous code after compile/build

I have a .BPG project which has a collection of .DPR project files.
Opened a .PAS file
I changed some line of code in a .PAS file of an project.
Saved it
After changing the source code, I tried COMPILE on that project.
First it says "Compiled" successfully.
Now I see the same .PAS file, the changes were lost. Codes changed at step 2 was lost. It is having the previous code only.
The behavior is same for BUILD too.
Anyone knows about this problem?
Thanks in advance.
Update
One more hint:
.DPR Project Name is XX.dll In IDE, there is one file with name XX_TLB.PAS in that project. In this file only I tried to change some code, which got reverted after compiling/building. Now I tried to rename this file, which gave me a error message
Type Libraries must have the tlb extention.
Also can the .DCU and .PAS files be in the same directory? I entered this directory (where both .PAS and .DCU files exist) into the directories list under "Tools->Options->Delphi Options->Library - Win32"
XX_TLB.PAS files are protected files. Do not edit such files directly. In fact there is note on top of the file warning you from editing the file.
They are regenerated each time the type library is refreshed.
See Code Generated When You Import Type Library Information.
This refresh could be done by the IDE each time you compile/build your dll.
You will never edit this file because of the dependencies of a type library and registered com objects. Either you change the com object itself via the type library editor, or create a new unit that interacts with your ActiveX class.
The Delphi IDE doesn't undo changes, as a general rule. There's notable exception. When you create an empty event handler, and then save the source file, the IDE will remove that event handler. Perhaps that's what is happening.
The other possibility that occurs to me is that you have multiple copies of the file. I've known the following to happen:
You create a package containing Unit1.
You install the package.
You then make another project that contains a different Unit1. Perhaps a copy of the file in a different location, so that it looks like the same unit.
You then modify the copy of Unit1, but the IDE sometimes prefers to open the file from the package.
The bottom line is that beyond deleting empty event handlers the IDE won't undo your changes. So it seems extremely likely that you have multiple copies of the file. To get to the bottom of this, you need to get the full path to the file. In the IDE, hover over the tab with the filename and the IDE will display the full path in a hint. I suspect you'll find that you have two distinct files.

Delphi: Missing Dcu

[DCC Fatal Error] Unit1.pas(7): F1026 File not found: 'MyBitBtn.dcu'
Unit1 is a VCL Form for test purposes.
I have installed a design time package which contains a custom component that derived from TBitBtn. I can load the MyBitBtn in the Delphi IDE, load up the custom images I coded in design time and it seems like it works fine, at least visually. I get the above compile time error when I try to compile the test project.
I have a package group that has one design time package and one run time package. Design time package registers the component and Runtime package inherits the TBitBtn and has the custom code in it. The design time package contains the RunTime DCP file in the requires section.
The moment I insert the custom button on the test form, IDE creates the USES clause for MyBitBtn file. And that file apparently can't be found. Shouldn't that be part of the package installed?
Most probable you did not set 'Unit output directory' option in your runtime package, so package .dcu's are not available; I usually set it to $(BDSCOMMONDIR)\Dcp and have no problems.
Generally, the .dcu's of a runtime package should be available via global IDE library path if you want your package to be available to any project:
.
You should either use one of the existing paths or add your own.
The design part works, but for run time, the compiler must be able to find the dcu.
You can do that either...
By adding the dcu folder to the library path of the IDE.
By adding the dcu folder to the search path of the project.
Or by adding the dcu explicitly to the project.
I would choose the first option. Since it's an installed component, you would want it to be available for any project, so setting the library path makes the most sense.
define the path where this dcu is stored in system environment. And dont forget to include it in Delphi env paths.
Go to ZEOS files, open packages, choose your version(DelphiXE10/Delphi7 ...) then go to the Win 32 file, open it and open Debug folder. Copy every thing, go to Program Files, Embarcadero, Studio, 17.0, lib, Win 32, Debug and paste, do the same in every win32 folder... Hope it helps :)

recompile/rebuild Delphi 5 code using .dpr file

I am trying to recompile/rebuild an old application program developed on Delphi5. I used the same Delphi5 software on an XP computer.
I did some minor corrections to the codes of a couple of forms and units. When I recompile using the .dpr file it comes with a fatal message: File not found System.pas
I added in .dpr file on the link path to this file BP folder. No success and the same message. Any clue will help.
Probably Library Path is broken after running some buggy component installer. In modern IDE's look for Tools -> Options -> Library -> Library Path from main menu (should be slightly different for Delphi 5).
System.dcu file lives in $(BDS)\Lib path for Delphi 2007.
The "File not found System.pas" error often isn't really because it can't find system.pas. It's some other problem that manifests as this error.
It can be:
Duplicate Path entries in the Library Path.
Too many entries in the Library Path - I think the limit is 99.
Path to a package in Library Paths too long.
Path to a package in Library Paths corrupt.
Environmental Variables not set correctly.
and possibly more if you Google "system.pas not found"
Marjan is right.
But also add ${DELPHI}\LIB\OBJ
If you still have a dcc32.cfg with the project, or a .cfg with the project, open it up to see if the settings in there are correct. Otherwise delete the .cfg or edit it to reflect the proper path to the bin and bin\obj directories.
A .dpr file is the main project file for a Delphi 2,3,4,5,6,7 project.
You have not given any details like WHAT WAY OF BUILDING SOMETHING of delphi you're using (the code is Delphi 5 level code, but you are not telling me for example, if you built the project inside the Delphi IDE or from the command line compiler DCC32), and what other files you have installed. You haven't mentioned if the library paths and so on are configured (either for the IDE, or for the command line environment, both of which are separate tasks).
An inability to find System.pas suggests to me that you might be running the command line compiler (Dcc32) instead of the IDE to build the project, and you have forgotten to mention that. That usually means you have to set up the Options (dcc32.dof) file for Delphi, so that command line building with Dcc32 can work.
What exactly do you mean by "When I compile with the .dpr file"? Instead of making people guess, show the commands you typed, exactly, and the error message, exactly. If it helps, use screenshots or text grabs.

Delphi: Required package not found

I'm trying to build 3 packages, A, B and C. A defines some base classes that are used in B and C. I've got all 3 of them in the same project group, all set up to output to the same custom BPL output folder. This folder is in the search path for B and C. But when I go to build B and C, the compiler chokes on the Requires list. "Required package 'A' not found."
How do I tell B and C where to find A so they'll build correctly?
Either the package can't be found, or the compiler is confused. In the later case, a restart sometimes helps. Then a manual build from all packages in order.
If it really can't be found, check if all package (bpl and dcp) and dcu files are available. You need both.
If this happens when the IDE is trying to load a package: your package output directory (where the *.bpl files go) has to be on your system's PATH environment variable. Packages are statically linked DLLs, Windows has to be able to find them to load them.
If this happens when building the packages: any/all of your DCP output directories (where the *.dcp files go) have to be in the dependent projects' search path so that the compiler can find the compiled packages.
You can also leave the DCP output directory of the package project empty - in which case the global DCP output directory set in Tools\Options\Library is used; the dependent projects then don't need to include it in their search path.
It is possible that the name of the required package is incorrectly specified in the 'requires' clause of the package you are trying to compile. Let's take an example:
We have two packages - VirtualTreesR.dpk and VirtualTreesD.dpk. VirtualTreesD requires VirtualTreesR. They both have the '16' suffix, so they both are displayed in the Delphi project manager window as VirtualTreesR16.bpl and VirtualTreesD16.bpl. You may think that these are the names of the packages, but you are wrong. The names of the packages are still VirtualTreesR and VirtualTreesD, not VirtualTreesR16 and VirtualTreesD16.
When VirtualTreesR.dpk is compiled Delphi produces two files (I don't talk about DCUs here) VirtualTreesR*16*.bpl and VirtualTreesR.dcp. See the difference?
Then we attempt to compile VirtualTreesD.dpk and get the error: "[DCC Fatal Error] VirtualTreesD.dpk(35): E2202 Required package 'VirtualTreesR16' not found".
The error happens because the 'requires' clause of the VirtualTreesD.dpk package contains the following lines:
requires
designide,
VirtualTreesR16;
Delphi tries to find VirtualTreesR16.dcp and fails even if the Delphi search path and the PATH environment variable are set correctly because there is no VirtualTreesR16.dcp. Only VirtualTreesR.dcp.
The solution is to fix the 'requires' clause so it will look like the one below:
requires
designide,
VirtualTreesR;
Hope it helps.
P.S. This a quite frustrating issue because this name mismatch is not obvious and its fragments are scattered across different settings. Delphi could be more specific if it specified what file exactly it tried to find (e.g. 'VirtualTreesR.dcp' instead of 'VirtualTreesR').
I would check to make sure where you are writing the .dcp files for the packages. once you have this, check that the search path of each package has an entry for the .dcp output folder.
I sometimes receive the "package not found" error when adding required packages via the Delphi Project Manager context menu. (Open a package, right click "Requires", choose "Add Reference..." command)
Instead it's easier to add the required package by editing the package project file manually:
Select the package in the Project Manager. MyPackage.bpl for example.
Ctrl+V to open the project file.
Add the required package to the requires clause.
Ensure the required package *.DCP file is in the package search path.

Resources