I've just noticed that whenever I do an incremental compile (ctrl-F9) of any of my Delphi 2010 projects, all JEDI units referenced in my project are recompiling although they have not been changed in any way. In fact, if I create a new project, drop a JEDI control on the form and compile, I see all JEDI dependencies getting recompiled. If I think hit ctrl-F9 a second time without making any changes in my project, the same thing happens.
Anyone know what's causing this?
Update: The problem appears to be related to the subdirectory jvcl\run on my system. All units in this folder are getting recompiled each time I do a Delphi compilation (even without touching my project source). The compiled dcus are getting and left in this subdirectory on every compilation, even though the compiled dcus already exist in jvcl\lib\d14. I do not have jvcl\run on my library path.
Additionally, if I move the jvcl\run directory elsewhere on my hard disk my project compiles and links successfully, presumably finding the dcus in jvcl\lib\d14 (which is on my path).
Sometimes you will see the unit name flash by on the compile progress screen, even when it is not being recompiled.
To know for sure, check the date of the Jedi DCU's before and after compile.
Also, how did you install the Jedi controls? If you use the default installer, then they shouldn't compile ever (they are compiled at install). If you just dropped all the source into your library path, then they will recompile on a build, or if they are changed (and various other conditions).
There are a few placed to check for your "jvcl\run" path in your settings.
The first two:
Tools|Options
Environment Options|Delphi Options|Library-Win32
(1) "Library Path:" Edit Box
(2) "Debug DCU Path:" Edit Box
The Third is:
Open Your Project
Project | Options
Directories/Conditionals
(3) Search Path: Edit Box
And finally if you compile via the command line you need to check what you are passing in the DCC32.CFG and/or PROJECTNAME.CFG and the command line parameters to DCCC32.
The reason your compiled DCU's are getting placed in directory your source is in is because you have not set an "Unit Output Directory"
Related
I'm still using Delphi 5.
I have a program which is a rewrite of an earlier program and in fact uses the root unit from the earlier program. When I compile it, Delphi doesn't link the BPLs into the EXE for some reason. New programs and old programs compile fine, so the problem is obviously with this one program. I've compared the project options for Linking and Compiling with other programs which are linking just fine. The compiler options in the main unit are the standard ones.
While the program is on my development box, it runs as expected, obviously reading the BPLs in the development area. But of course it won't run on another machine unless I copy the BPLs over, which is obviously not very clever.
I've read everything I can find on the subject, but although I've found references to linking not working, I haven't found anything which helps to work out why the linking isn't working in just this one case.
Can anyone point me at some documentation about this or point out something I've obviously missed looking at? I know it's something I've done, but despite spending hours on it I can't work out why!
Since there are no errors generated, I can't show you where it went wrong. Any suggestions about where I might find the problem would be much appreciated.
If you go to the Packages tab of your Project Options, is the Build with runtime packages checked?
If it is, you need to deploy the other packages to other machines if they aren't already on those machines at locations where they can be found by the OS.
If it isn't, Delphi will compile and link your project as an .Exe file and the code from the DCUs in the packages will be statically linked into your .Exe so you won't need to deploy the .BPLs (and they would be ignored even if you did).
AFAIK, when Delphi compiles a project to an .Exe (that is, if Build with runtime packages isn't checked), the compiler gets the other units' code to link from the .DCU files, rather than from the .BPL files. If it can't find the .DCU files, or you have told the compiler to do a "Build" it will attempt to generate the .DCUs them from the corresponding .PAS files if it can find them either in the project directory or via the Seach Path under Directories/Conditionals.
When I open my project and I double click on a specific pas file in the Project Manager, bds.exe freezes and continues using 25% of the cpu. I have to kill the process through the Windows Task Manager. (1)
When I open my project and I press F12 on that exact same file, I see what I would have expected to see earlier, the contents of the pas file.
When I open my project and I compile it first, then double click on the file, everything is fine.
I'm trying to figure out how, what I assume to be a mismatched DCU file, snuck into my project and what the best way is to prevent a similar issue in the future. Can I force all DCU files to be rebuilt? Can I simply delete all dcu files and recompile or is that a dangerous thing to do? My DCU files are currently also stored in the same directory where I keep the pas and dfm files, that is a bit messy.
(1) our application also shows behaviour in production where it sometimes crashes while it continues to use a steady cpu usage or simply continues to work as expected but shows a steady cpu usage in the background. We have been unable to trigger it in a compiled version but see it popping up from time to time. We assume the dcu mismatch is at the source of this problem.
There are numerous issues in your question, some entirely unrelated, but the assumption that the problem is a "mismatched" DCU is unlikely to be correct (by which I presume you mean an "old" or otherwise incorrect DCU compiled in the past or with different source).
First your problems.
IDE Behaviour
The problem with the IDE locking up when double-clicking a unit in the Project Manager is unlikely to be anything to do with a "mismatched" DCU.
Do you have source files located on a network drive ? Is this unit such a file ? Is that network location available/valid ? i.e. is the path to the file using a network drive letter that is no longer mapped or otherwise not available ?
If there is no explicit path in the unit reference in the DPR, do you have network locations listed in your system, IDE or project PATH ?
Difficulty accessing file locations is the most likely explanation for the IDE appearing to lock up when trying to simply open a file.
As to why it should behave differently when using F12 rather than the Project Manager, unfortunately the Delphi IDE is notorious for using different mechanisms to achieve the same thing in different places so it isn't surprising that sometimes when one of these mechanisms breaks the others still work (and can give different results even when both work).
Runtime Behaviour of your App
If we work on the basis that you do indeed have a "mismatched" DCU then performing a full build of your project will resolve that mismatch, as long as you have the source for all the required DCU's and that the correct and appropriate source for each DCU is available.
However, even though the mismatch may be resolved, rebuilding may or may not fix the issue, depending on whether that issue remains in the source code for that unit itself when recompiled.
The simple fact of the DCU being "mismatched" cannot cause aberrant application behaviour. With the exception of OS or RTL bugs etc, if there are errors in the behaviour of an application then those errors will be the result of errors in the source code as compiled.
Simply recompiling source code containing an error will not remove that error.
As such, if there is such an error then far more information will be needed if anyone is to be able to give any assistance on that score (and this should be a separate question, once you have done some initial debugging and diagnostics yourself).
Runtime Packages
If you are using runtime packages then things get more complicated because with a runtime package, the DCU employed for any particular unit could be part of a package file. In that case, the DCU file on disk is produced when you compile the package itself but any project that uses that package will not use the DCU on disk but will instead use the version that has been compiled into the package.
So if you are using runtime packages then as well as rebuilding your project you need to also rebuild any and all runtime packages that may have changed.
Now, for your actual questions.
Q1: Can I Rebuild all The DCU's ?
Yes, of course. But see above w.r.t Runtime Packages, if your project uses them.
I would strongly recommend that you change your project settings to output DCU files to a specific location, separate from the source files.
For example, you could have a project specific DCU folder using a relative path. i.e. set your DCU output folder to something like ".\dcu" and create a dcu folder within the folder where your DPR is located.
For Delphi versions supporting multiple platforms and configurations it is best to include the environment variables for the platform and configuration in that path, so that you don't end up using units compiled for DEBUG in a RELEASE build.
e.g.
.\dcu\$(Platform)\$(Config)
or
.\$(Platform)\$(Config)\dcu
What Is Compiled in a Build ?
When you do a Build on a project (as distinct from a "Compile"), all units referenced by that project will be recompiled, with the exception of any VCL/RTL units (i.e. those provided with Delphi). Those get special treatment.
At a minimum, rebuilding a project will forcibly recompile all units explicitly listed in the DPR, but will also recompile all other units that are used by those units (or units that they use etc etc).
NOTE: DCU's With Missing Source
A unit will only be recompiled if the source can be located.
If you have a DCU and the source file is missing or cannot be located on the project, IDE or system path, then the compiler will simply assume that you want to use the existing DCU.
This is the case even with a full "Build".
3rd Party DCU's
It may seem obvious but you should also be careful that you don't delete DCU's that may be your only copy of any 3rd party libraries you may be using for which you do not have the source.
This is highly inadvisable, but I guess we mustn't rule out the possibility that you may be in this situation.
Q2: Should I Delete all the DCU's ?
In general, yes. As noted above, even a full build will be successful if you are missing the source code for a unit that is referenced, as long as there is a DCU (or required package, if using runtime packages) that can be found.
So the only way to be sure that you have the current source for all DCU's is to first delete the DCU's that any previous builds may have used.
This is of course much easier when you have a specific, explicit location in which all your project DCU's are output.
It's slightly more involved if you are using Runtime Packages, though if you are organising your DCU's sensibly then the only real complication is that you need to repeat the same exercise for all the projects involved, working through starting each of the runtime packages that are used and finishing with the projects that in turn use them.
Yes, you can rebuild all DCU files in your project;
In the project group window, right click on the project and select Build.
It is OK to delete all DCUs in your project, but not necessary (or desirable in case you make a mistake...).
Note that this only builds DCUs explicitly in you project (as shown in your project tree) not any implicit ones imported as a result of your uses clauses.
Three things may be going on that have not been adressed in other answers.
Note that I only have experience with Delphi XE2 and Seattle 10, but they may apply to your version.
Delphi can be slow when switching from form to source view, especially if you have many components on your form. In migrating from XE2 to 10, we noticed an improvement here. We are talking seconds here, this does not seem to be your issue.
Delphi can be notoriously slow when switching between projects. After a switch the IDE can take a very long time (20-30 seconds) to respond. You cannot type anything; code completion takes a long time; initiating a project search with Alt-S-D waits a long time, then fails. In migrating from XE2 to 10, we noticed a large deterioration here.
Conditional compilation. If you have IFDEFs in your code compiling stuff for one project but not for another, your IDE can hang completely, and there's nothing else you can do then killing BDS.EXE. This happens in Delphi Seattle 10 if you switch projects and accidentally Compile instead of Build.
You may experience variations of these.
I usually don't show compiler progress when compiling, but I decided to turn it on.
I noticed that when my program compiles, it is also compiling the components that it uses. For example it uses Toolbar2000 (TB2K) and in the compiler progress window I can see it says compiling TB2kDock.pas, etc.
Is this by design? Is there perhaps a setting where I can tell it not to compile components every time (Since they are not changing) and only compile what is in my program's actual source code directory?
Compile is supposed to just recompile your changed units and create new dcu files. The linker always has to rebuild the Exe from the dcu files. Build recreates dcu files for all pas files whether you modified them or not.
before you look into this you have to understand that COMPILING your application and BUILDING it are two different things. As far as my understanding goes when you COMPILE the application Delphi modifies the exe and simply changes what you have changed in your applications code. When you BUILD the application it replaces the exe.
So when you build the application if will recompile all the units of the components that is listed in your settings and options, but when you just compile it (Even if it says its compiling that unit) its actually just searching for changed pieces of code in that unit that needs to be modified in your exe
I am speaking under correction of course
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.
Sometimes as I am debugging step-by-step, just before a FormCreate Event or just after the FromDestroy the debugger starts to open DevExpress units (cxContainer.pas, ...) and so before FormCreate my "F8" leads me to cxContainer instead of going into the next line of my code.
(this is just an example, it can happen of course with any 3rd party library)
How do I tell the debugger "debug only my units" (only the pas files listed in dpr file?)
Of course sometimes it is useful to debug libraries, but in most cases it isn't.
You'd better follow VCL convention for your third-party components:
Change DCU output path in all the third-party packages to a folder different than the folder you store the PAS files.
Compile each package once in Debug mode, and save the generated DCU files in a folder (e.g. Debug DCUs).
Compile each package once again, but this time in Release mode, and save the generated DCU files in a folder (e.g. Release DCUs).
Go to Delphi options and add path of release DCUs to "Library path".
In Delphi options, add path of source files to "Browsing path".
In Delphi options, add path of debug DCUs to "Debug DCU path".
This way, Delphi will only see release DCUs of that third-party component when you are compiling your project, so the debugger cannot step into the source code.
On the other hand, since source path is included in "Browsing path", you can still navigate to the source code inside IDE by Ctrl+Click on unit name, or anything defined in those units.
If you want to debug component, you can go to "Project | Options | Delphi Compiler | Compiling", and enable "Use debug .dcus". This will force compiler to use "Debug DCU path" instead of "Library path".
VCL works the same, generally you don't step into VCL source code when you are debugging your project, but if you enable "Use debug .dcus" you can debug VCL source code too.
JVCL also organizes its packages and source code the same way.
EDIT:
If you take this approach, and want to have code browsing (Ctrl+Click) working; please take note that when you compile release version of packages, you must set Symbol Reference Info in "Project | Options | Delphi Compiler | Compiling" to "Reference Info"; otherwise, Ctrl+Click won't work for those units. By default, Release build configuration sets Symbol Reference Info to None.
A quick and simple solution is disabling the DEBUG switch ({$D-}) for any libraries you're using. Many libraries (including DevExpress) use a global include file, usually at the top of each source file, or right above or below the "unit" statement (e.g. unit cxContainer; {$I cxVer.inc} interface ). Open that include file (click on it and press CTRL-Enter) and add {$D-} right at the top, and comment out any existing {$D+}.
There is only one way to tell the compiler not to debug a unit: compile it without debug information.
If you have the source to your libraries, you can rebuild their package after having turned off the "include debug info" compiler option for each package in the library. If you are lucky, your libraries will include an .inc file which specifies the compiler options they need and which they include in each unit. In that case all you have to do is edit this inc file and rebuild all packages.
If you don't have the source to your libraries, the library makers may have provided two sets of dcu's: one compiled with, the other without debug information. In that case, simply point your library path to the one you need.
Turn off debug info in units you don't want the debugger going into.