Joris Groosman
Joris Groosman

Reputation: 781

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:

enter image description here

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.

Upvotes: 4

Views: 5335

Answers (3)

Delphine
Delphine

Reputation: 49

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.

Upvotes: 2

Donald Klopper
Donald Klopper

Reputation: 31

@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.

Upvotes: 3

David Heffernan
David Heffernan

Reputation: 613013

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

Upvotes: 5

Related Questions