Can I have Delphi automatically compile RC files? - delphi

I thought Delphi would automatically compile resource files when I add them to my program, like
{$R 'resource.rc'}
but the linker returns an error message Error reading file "D:\resource.rc". When I look into project options, however, brcc32.exe is explicitly listed as resource compiler to use:
I know I can invoke the resource compiler from the CLI, but I'd prefer to have resources compiled automatically. How can I do this? I'm using Delphi XE8.

You need to add the resources to the project using the Resources and Images item on the Project menu.

#Joris Grootman I know I'm VERY late to the party, but as another alternative you could set up a "pre-build" event in Delphi (Project Options | Build events | Pre-build events | Commands) to run the resource compiler command before the project builds, and since it's just a quick process you should not notice it slowing down the Delphi build.

Its better and more flexible to list all of your resources in an RC file and then add this file to your project (Project > Add to Project), The IDE will add the $R directive to the project's DPR file, and the RC file will now appear in your project files pane where you can double click it to open it in the editor so you can add/edit/delete resource as you wish.
This way, Your RC file will be compiled automatically and linked to your executable whenever you compile your project.

Related

How to add a cpp file to an existing project in Borland C++Builder 5?

Adding the line #include "newProc.h" to unit1.cpp and unit1.h is not enough. It leads to an error:
[Linker Error] Unresolved external 'newProcClass::newProc()' referenced from C:\PROGRAM FILES\BORLAND\CBUILDER5\PROJECTS\TEST1\UNIT1.OBJ
(newProc.cpp was not compiled)
Make or Build Project1 with unit1.cpp's line #pragma link "newProc" (obj) is ok, but I want to compile the newProc.cpp in each Make or Build process.
Borland C++Builder 5 is very old - but I am pretty sure it still has a project view which shows the files used by the project. Right click on the project and select "Add..." and then navigate to the .cpp file you want to add.
If you use the main menu: File | New, and then select either VCL Form or C++ unit (the latter if you are going to develop a C++ file with no VCL GUI, can still use VCL helper functions and classes), then the file is automatically added to the project, and you don't have to do the above procedure.

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 to force resource compiler on each compile?

Is there a project/compiler/linker-setting that can force brcc32.exe to run on some or all .rc files included into the project? By default only .rc files that have changed get re-compiled, but not when any files included by the .rc are. For now we manually delete the .res file(s) to force a re-compile.
Update: inspired by the accepted answer, I wrote this: https://gist.github.com/2868141
Haven't used Delphi for years, but as far as I remember you can define pre-build events, can't you? You could touch all the rc files before building.

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.

How to interpret .otares file in Delphi XE2?

There is a new file [project-name].otares created in Delphi XE2.
The wiki says:
File with unknown resources generated during upgrade of pre XE2
project. (Unknown resources are resources that are not included in the
build configuration, like version info, icon, manifest or styles.)
How I can read this binary file meaning. Which resources exactly haven't been migrated?
After opening the otares file with ResEdit tool I displayed the information I needed:
You can open the file in a resource editor, for example: XN Resource Editor, ResEdit, Resource Hacker, Visual Studio etc.
Somehow such a file was created in a new package of mine by Delphi 11. A warning was being issued at compile time that duplicate resource from .res file was discarded. Also at other Delphi 11 installation it didn't build anymore without an error message (just that warning which didn't cause build issue at the other project).
Solution was to right click the project and pick "View source", then remove the {$R *.otares} that had been placed before the {$R *.res} in the .dpk file (for app project instead of package project it would be the .dpr file)

Resources