How to interpret .otares file in Delphi XE2? - delphi

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)

Related

Can I have Delphi automatically compile RC files?

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.

Delphi .proj file missing .dpk file

I recently got project in delphi which I need to rearange, I'm totally new in delphi so I'm searching my way in environment and language. Question, in my project group I have two files with .dproj extension, no corresponding .dpr file so when I try to load them I got msg:
"Canot open file xxxx.dpk, system cannot find the file specified"
Did the old programmer forgot to copy all files so I'm missing this, or is this some kind of file (.dproj) that I only add as a reference so I don't need to have corresponding .dpk or .dpr file??
The .dpk file is the top level Pascal source file for a package. It is the package equivalent of an application project's .dpr file.
The original developer should have supplied it to you. Ask them to do so.

Unable to open or even add Resource files in my Delphi 7

Every single time i either try to open or add a resource file to my project or just open it within delphi it will throw me an error (I have tried .rc,.res,.rc..all kinds of extensions) and it will say that the file has been truncated or that Delphi cannot open or add this type of file. any ideas?
You cannot open a .res file in the Code Editor, as it is a binary file. You can open an .rc file, as it is a plain text file.
You can certainly add both .rc and .res files to a project, though. The IDE should not complain about that.

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.

I can't include a version number in this old Delphi project I inherited. How do I fix it?

I have an old Delphi codebase I have to maintain, lots of DLLs, some older than others. In some of these DLLs there is no version information in the Project Options dialog. The controls for adding a version are greyed out and I can't even add a version number by manually editing the .DOF file. How can I include a version number in these projects?
Check if the default .RES file exists in the project source location. Delphi includes the version number of the project in a .res file with the same name as the .dpr file. If the .RES file does not exist, the simplest way to recreate it is to add the {$R *.RES} compiler directive to the .DPR file, immediately after the uses clause.
library foolib;
uses
foo in 'foo.pas',
baz in 'baz.pas';
{$R *.RES}
exports
foofunc name 'foofunc';
end;
As soon as you add the {$R *.RES} compiler directive Delphi will tell you it has recreated the foolib.res resource file.
It seems the resource directive {$R *.RES} is missing (or enclosed in conditional defines) in your .dpr file so that the IDE doesn't find it.
You can create and embed resource files in libraries created under Delphi, by using the $R directive.
This link has information relevant to constructing the RES file.
Delphi has its own resource compiler: BRCC32
I use a build control system (FinalBuilder) and that is able to add version resources to all my DLLs and EXEs that are all coherent. Therefore I can be confident that the file set is all labelled with the same build. There are some Delphi projects that don't have versions by default, and FB will add them for you anyway.
Inclusion of version info in dll's is a bit erratic. If you specify a lib_suffix the version info is not updated.

Resources