How to recompile modifications to VCL source file (Menus.pas)? - delphi

We have a modified menus.pas.
At
uses ...,Controls,...;
The compiler raised a fatal error:
[DCC Fatal Error] Menus.pas(*): F2051 Unit Controls was compiled with
a different version of Menus.TPopupMenu
tried:
deleted all dcu in the project.
build
build all
tried adding the file to library path which leads to add db folder(from vcl too) and then to
[DCC Error] jpeg.pas(872): E2065 Unsatisfied forward or external declaration: 'jpeg_save_markers'
which is a dead end.
deleted the controls.dcu (all 3) and the delphi did not know automaticaly to recompile them, instead reported that controls.dcu is missing.

Here is how I handle modifications to VCL source files:
Make a copy of the file in your project structure. Either add the file to your project, or make sure the search path finds your modified file.
Make modifications, but only in the implementation section. You are not able to modify the interface section if you use any other units that themselves use the unit you are modifying.
Explicitly set the compiler options at the top of the modified source file. Use default Delphi options, as found by pressing CTRL+O O in a default vanilla project.
I'd guess that one of the final two bullet points is what is tripping you up.

In Delphi XE7 (and below) themes and styles are totally unusable.
So, I patched the file ( Delphi XE7\source\vcl\Vcl.Themes.pas ) add it to the project file, compiled it and got a DCU. I replaced the old DCU ( Delphi XE7\lib\win32\release\Vcl.Themes.dcu - same for "debug" folder) with the new one. Everything works smooth now. I don't even have to link the PAS file to my projects.

Related

Unresolved External After Project Migration

I'm using C++Builder 10.4.1. I've migrated a simple project containing 3 forms. The main form contains a TDriveComboBox. When I try to compile I get these errors:
[ilink32 Error] Error: Unresolved external 'Vcl::Filectrl::TDriveComboBox::' referenced from (then it lists the path to the main form's OBJ file)
[ilink32 Error] Error: Unresolved external '__fastcall Vcl::Filectrl::TDriveComboBox::GetDrive()' referenced from (then it lists the path to the main form's OBJ file)
I've even tried to delete the TDriveComboBox and replace it, but that doesn't help.
What's the problem and how can I fix it?
I would:
delete all temp files (obj,exe,tds,...)
add new temp TDriveComboBox on form with this problem
compile and run.
If that does not help then sometimes manually #include VCL header containing the component into form *.h file helps reset the compiler/linker so search the VCL inc folder for TDriveComboBox In mine system its in here:
c:\Program Files (x86)\Borland\BDS\4.0\include\vcl\FileCtrl.hpp
So add something like:
#include <FileCtrl.hpp>
or
#include <vcl\\FileCtrl.hpp>
into your form *.h file... but even this sometimes fail. In my experience the problem lies in the project file (*.bds, *.bdsproj, ... or whatever extention the newer versions got) so its a good idea to backup it while the compiler works as should... As it sometimes corrupt it self especially for big projects.
Sometimes also helps if you move:
#pragma hdrstop
line to different locations (few lines down or up). If you're lucky it can also reset the compiler/linker after which you can move it to original location. However this helps only occasionally (like 1:20). And you also need to try few locations
In case nothing works just create new empty project and copy the forms and stuff into it and add it to project... Each form has 3 files (*.h,*.cpp,*.dfm) and do not forget to add to your project whatever you need (DLL *.lib,...) if its not linked directly with #pragma link for all the 3th party custom stuff your app uses
Once (also after migration from BCB5 to BDS2006) even this did not help for one of mine projects. I was forced to create also the forms (with all the components but without functionality just place them on forms) and then copy the stuff from old App... However if you got too many components it will be a pain in the ...
I have found for most of these problems created by the ide in converting my 10.3.3 projects to 10.4.1 can be solved by an annoying process as described below:
open the form.
on design tab, switch to text view.
switch to form veiw.
under project, recompile just the form.
now run project.
This has solved most of my unresolved's except _CG_*.

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

How do I make my changes to XML-related source files take effect?

I want to make changes to the xmldom and XMLDoc files. I tried to, but I don't know how to test those changes because the program does not seem to be running the code in those files. I tried using a ShowMessage to see if that code was being accessed but it never showed up. Even if I rename the directory the files are in, the program still compiles fine as if it is not actively reading the files at run time but instead has the information stored elsewhere.
How can I change these namespaces and then make sure that the changes are being included in my next compile?
Update
Well i'm looking for an answer in general.. Because I have had this problem in multiple situations.. But for specifics Changing XML node attribute value gives "Namespace error" (here the answer talks about changing the 'AdomCore_4_3') I want to be able to change it and have the change show up when I compile.
If you've removed the compiled DCU files from your environment, and your changes still aren't being compiled into your project, then you either aren't really using those units at all, or you have run-time packages enabled.
With run-time packages, the compiled code is accessed from the BPL file, not the DCUs. You're not allowed to distribute modified BPL files, so if you're going to modify the Delphi-provided source code, you need to make sure you're not linking the package with the XML units to your project. You can control that in your project's linker options.
As long as you are not making changes in the interface section of the units, only the implementation section, then you can disable use of Runtime Packages in your Project Options and then add the modified source files directly to your project. The compiler will compile them into new .DCU files and use them instead of the default .DCU files.

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.

Resources