14

I am getting this rather confusing compiler warning:

[DCC Warning] W1056 Warning: Duplicate resource: Type 14 (ICON GROUP), ID MAINICON; File C:\dev\dispense\trunk\dev\source\mountaintop\dispense\MtnDispense.res resource kept; file C:\dev\dispense\trunk\dev\source\mountaintop\dispense\MtnDispense.res resource discarded.

In case the formatting isn't clear; the two paths it mentions are identical.

The application doesn't have any entries under Project->Resources

The application has a custom icon, defined under Project->Options->Application->Icon.

Does this warning mean anything? And how can I remove it?

awmross
  • 3,789
  • 3
  • 38
  • 51
  • Related: https://stackoverflow.com/questions/26468135/h2161-warning-duplicate-resource-type-10-rcdata – Gabriel Mar 21 '22 at 10:01
  • Related: https://stackoverflow.com/questions/71518287/h2161-warning-duplicate-resource-type-10-rcdata-id-tfrmabout – Gabriel Mar 21 '22 at 10:03

4 Answers4

31

It means the resource file is being imported more than once. You should only have one

{$R *.res}

in your dpr file. To fix the error, remove the extra ones.

crefird
  • 1,590
  • 11
  • 17
  • 2
    Yes! I had a line in the .dpr that looked like this: "TSomeUnitU in 'subdir\TSomeUnitU.pas' {$R *.res},". No idea how that got there (accidental paste??). I just removed the bit in braces and the warning is gone. – awmross Nov 14 '11 at 01:48
  • @awmross - I had something similar recently, not sure if it was an IDE glitch or me, but I suspect it was a glitch. – Gerry Coll Nov 14 '11 at 03:56
  • 1
    I have sometimes had this error when there was not a duplicate {$R ...} directive. In those cases, I deleted the main project .res file (which had become corrupted). – Warren P Nov 15 '11 at 00:59
  • This happens sometimes when you use "Add to Project" and add a new unit. It appears that the IDE lose the existing `{$R *.res}` and adds a new one at the end of the first unit in the `uses` clause in the DPR file (just like your comment says you found). I think it's because there's no `{Form1}` at the end of the first non-standard unit name. – Ken White Jul 04 '13 at 14:27
  • This just happened to me. I added two files to the project at once using ctrl-click multiselect. It seems that the IDE (D2007) couldn't handle adding two files at once. – dan-gph Oct 12 '15 at 02:16
  • It's 2078 AD and the IDE still screws the .dpr up on adding/removing units. – Atys Mar 16 '17 at 12:27
8

I reproduced your problem:

program ProjectName;

uses
  Forms,
  Unit1 in 'Unit1.pas' {Form1};

{$R *.res}
{$R *.res}

begin
  Application.Initialize;
  Application.CreateForm(TForm1, Form1);
  Application.Run;
end.

Remove the second compiler directive. Or there is a {$R ProjectName.res} somewhere in another source file.

NGLN
  • 43,011
  • 8
  • 105
  • 200
2

In my case the problem was like this:

Program xyz;
 
uses
  FastMM4,
  Windows,
  SysUtils,
  Forms,
  cIO,
  FormManager in 'FormManager.pas' {FrmManager} {$R *.RES}; <----- HERE

{$R *.RES}

The IDE corrupted the DPR file and accidentally added an extra $R directive in the 'uses'. Actually, this is not a "happen once" case. I see this from time to time.
This explains your:

No idea how that got there (accidental paste??).

Gabriel
  • 20,797
  • 27
  • 159
  • 293
-1

The name of application: Teste.dpr, name of resource rc : Teste.rc that generate Teste.res, the same name generated by Teste.dpr, this is the problem.

I rename Teste.dpr to UsandoRecurso.dpr then I can compile correctly.