XE7 link runtime package issue - delphi

I am moving my code from Delphi 2007 to XE7. My program use late binding package way. So I compile my application with "link with runtime packages" options. I used this way for a long time with 2007.
But in XE7, same package structure, cause:
"Unit X was compiled with different version of Y.Txyz" error message.
Unit X in one of my package. Y unit is in a library package also. Relation seems ok. Why XE7 gives this error?
I tried following ways:
I cleared .dcu files.
I open Build as Needed option in packages.
Build All every package and application files.
Compiler pass some errors but repeat ".. compiled with different version .." type error somewhere else..
I am not clear about this issue. Is there changing in logic of XE7?
Best Regards

I focused on the problem and I realised some differencies XE7 from Delphi2007.
Compiler search for *.dcu files. If there is more than one version of *.dcu files produced somehow, than one of the package can produce "unit compiled with different version" error.
If source package declared as "Rebuild as Needed", when compilingg other packages using source package, compile units again and produce new dcu files. So, Instead, check "Explicit Rebuild".
I created common dcu path and declared in "unit output directory" for all packages.

Related

Delphi DLL Project does not find unit in custom BPL except when "Link with Runtime Packages" is True

I have a DLL project that has a dependency on another project of mine, which is packaged in a BPL.
In Delphi, when trying to compile the DLL project, it will not find the Units in the BPL, although the BPL is in the Search Path.
The weird thing is that when I check "Link with Runtime Libraries" then it compiles fine. However, that has other disadvantages, so I'd like to set it that to false.
Any advice?
The BPL is not used by the compiler, neither with or without runtime packages. When compiling with runtime packages, the DCP is used (which obviously is in the search path then). Without runtime packages you have to provide the DCU or PAS files.

Recompile modified VCL unit

I have to compile my project with a changed VCL unit. I use Delphi XE8. I copied Vcl.StdCtrls.pas from D:\Program Files (x86)\Embarcadero\Studio\16.0\source\vcl to my project folder where my .dpr file is localed, then I changed my copy of Vcl.StdCtrls.pas. I also added this unit to project tree. The problem is that with Delphi XE8 such method of recompiling VCL units no longer works. I put an obvious syntax error in my modified Vcl.StdCtrls.pas unit. Compiler does not report the error which means it does no even check the file. I always do a full build Shift+F9. I found a similar question How to recompile a specific unit from the VCL? but like I said, it no longer works, not for Delphi XE8.
Also, the modified unit is on my uses list in .dpr file:
uses
Vcl.StdCtrls in 'D:\Dev\MYPROJECT\Vcl.StdCtrls.pas',
...
// it does not help
This seems to be a bug. I guess you're using runtime packages. In XE7 such project will not compile - which is the correct behavior. In XE8 it compiles, apparently using the VCL runtime package and ignoring your modified unit.
Edit:
Note that even in previous Delphi versions, modifying a VCL unit while using runtime packages would still require you to repackage the modified packages and their dependencies (in this case, vcl and rtl).
In other words, you cannot simply use a modified unit while linking against a runtime package which contains another copy of that unit. Unit names must be unique within the full scope of the project, including the main executable and all linked runtime packages.
So the solution for you is to either:
not use runtime packages, or
repackage all required units into your own runtime packages, and link against them instead of Embarcadero-supplied rtl, vcl etc.

Where do I find the bpl file after I compile a package?

I want to create *.bpl file but I am failing to do so.
Specifically, I am trying to make JEDI plugins, but I have tried an empty pure Delphi package, too.
If I create a new package in Delphi XE3, I get an empty unit - if I "make" this project called "Package1.bpl", I get a .dcu file in "debug/win32/", but no .bpl file.
No error is reported by the compiler.
An empty JEDI plugin (bpl-style) only gives a .dcu, too, while an empty dll-style JEDI plugin gives a .cdu and a .dll file in "debug/win32/".
This is the first time I am trying to make a new package, so I am completely lost.
What am I missing?
Go to the Tools menu and navigate to Environment Options -> Delphi Options -> Library.
There you find the Package Output Directory and the DCP Output Directory. These directories are the default output directories for BPLs and DCPs, so the bpl will be created if your packages is compiled, but in a different directory from what you expect.
The JEDI plugins probably have their output directory configured otherwise in Project -> Options.
For those that don't want to travel into Delphi IDE/options etc, lately in Delphi XE it's something like this:
"C:\Users\Public\Documents\Embarcadero\Studio\17.0\Bpl;"
Your exact folder might be different based on 17.0
These folders also end up in the path environment variable of your system, bit dangerous and can lead to some mighty magic loading confusion ?!
"How's that BPL still loading after it was deleted from my local project folder ?" :)
Another solution is to add "." to your project settings without the "". Prevents you from having to modify your delphi environment options/settings, something you probably never want to do since JEDI and other projects may rely on these default settings to function properly. Only change it if you know what you are doing and how to correctly make JEDI and others work if it was changed, this may get tricky/hairy, probably requires search paths to be added.

Why Delphi says "Unit xxx compiled with a different version of yyy" if all my paths are correct?

First of all I would like to apologize for the question itself. I simply could not make anything better. Well, the question then follows with examples and detailed ...
I manually installed QuickReport Delphi 2006 from their sources. It is composed of two packages a "DesignTime" and a "RunTime".
My Delphi is configured to build the BPL files in "D:\BPL" and DCP files on "D:\DCP" for all packages compiled on my Delphi
The source code of QuickReport are in "D:\QuickReport" and their packages (design and runtime) are configured to save the compiled units (DCU) in the folder "D:\QuickReport\DCU." This was the only configuration done in the packages. Nothing is set up with different paths and, BPL and DCP files are placed correctly in the folders I've set up, as I mentioned earlier.
With these settings I was able to build and install QuickReport without problems (just a few compiler warnings, which I believe are normal). All QuickReport components appear in your palette in Delphi, which does not emit any error on start proving that the components are properly installed and all packages were found.
Now comes the test: I started a new win32 application, completely empty, just a blank form. Then it put a QuickReport component (TQuickRep). The first thing I noticed was that the unit "QuickRpt", which is automatically placed in the clause "uses" of the "interface" is underlined in red indicating that something is wrong.
When I perform a CTRL+ENTER in "QuickRpt" unit (uses clause), the Delphi finds the source file (.pas) correctly, which is in "D:\QuickReport" then I ran a BUILD ALL command and the following compilation error appeared:
[Pascal Fatal Error] Unit1.pas (7): F2051 Unit QuickRpt was compiled with a different version of QRExpr.TQREvElement
That's it!!!
This error is only happening with Quick Report. I have other third-party components installed using the same configuration as the paths and they all work properly.
Finally I was able to solve this problem. #RRUZ and another friend gave me the tip: An lost QuickRpt.dcu file on my system. There were a QuickRpt.res file also. I found them, but the place was very improbable to me: The delphi LIB folder!!!
Well, i have some clues about this bizarre thing.
Until Delphi 7, the QuickReport was shipped together with the IDE however, it was disabled by default. On that Delphi version, all we need to do is to register the bpl to gain full access to QuickReport!
On Delphi 2006, the QuickReport is not part of IDE and there are no BPL to register, however the guys at Borland forgotten to remove all files from the old QuickReport. The Delphi Lib Folder is one of the first folders to be checked on Delphi start, so, if there are old files there, new files on another place would be never compiled, generating the annoying error!
This problem may be present on Delphi 2005 too.

BCB / Delphi: I am doing something stupid - but what?

I have been away from BCB for over five years, and now I am having a st00pid n00b moment.
I am using BCB, and using a VCL component package for which I have the Delphi source.
I want to comment out a few lines in the Delphi source of the component (to not add a few toolbars in a form's OnCreate()).
So, I comment it out, and the syntax highlighting shows it as a comment. I build my package, just to make sure it gets recompiled and my out-commenting didn't work.
I breakpoint on the line before, step and the code which is commented out in the edit is executed (as if it is picking up an old OBJ ?).
What's my checklist here?
The answer will be awarded to whoever leads me to that D'oh! moment. Thanks
Well you're obviously linking to old code. You'll need to figure out what you're linking against and fix it.
Does your application list the Delphi package in it's "Build with runtime packages" list? If so, you're linking to the code in the delphi package, re-build that. The file you're interested in is the "BPL" file (that's the file you need to rebuild). Sometimes packages automagically build themselves (if they're marked as "Always Build") - but you're talking about an Delphi package used by BCB, maybe the magic is not that strong.
If you are not linking to the BPL then you're linking to the compiled version of the unit, a DCU or an OBJ, I don't work with BCB so I can't tell. Is the PAS file part of your project? If it's not part of your project then you're using the compiled unit and, as far as the IDE is concerned, you happen to be looking at a text file that has the same name as your compiled file (DCU or OBJ). Add the file to the project!
Is BCB actually capable of compiling PAS files? If it's not then you'd need to compile the PAS file using it's native compiler (Delphi). Maybe you've got a C++ only BCB that can't compile PAS files? Not sure such a version exists, but then again I've only been exposed to Delphi-only or RAD Studio environments.

Resources