Jump to content
lookin030577

Unsupported 16-bit resource in *.RC file

Recommended Posts

Hello everyone!

 

I am trying to compile my Delphi 6 project in Delphi 10.4. All issues with code have been solved but I encountered the problem with resourse file. In my old version of the project, I used RES file with some images/icons inside. The file is non-damaged and I can view/edit it via PEResourceExplorer.exe (https://www.portablefreeware.com/index.php?id=288).

 

First, before the compilation I simply replaced my new empty RES file (appeared automatically in my project folder) with the old one. The compiler passed everything without warnings but the execution has raised an error about "a resource not found" when attempting to load a resource by execution of code lines. This time, the old RES file is replaced back to the new empty one.

 

Next, I made a RC file and compiled it by brcc32 (in Delphi 10.4 "bin" folder, without any specific params) to get RES file. This file can be read by PEResourceEexplorer as well. Then I put the newly compiled RES file to the project folder... and it gave me exactly the same result as before. Of cource, in these two ways I used {$R MyProject.RES} directive in my *.DPR file. Also, the result is not sensitive to the selection of Project -> Options -> Resource Compiler -> Resource compiler to use: in both cases I have non-discriminate effects during compilation and running. 

 

Finally, I put the RC file with proper references to the original resources just into the project's folder, selected brcc32 in "Project -> Options -> Resource Compiler -> Resource compiler to use", replaced the directive in *.DPR file to {$R MyProject.rc}. Here, the compilation is terminated with the following message: [dcc32 Error] E2161 Error: RLINK32: Unsupported 16bit resource in file "...\MyProject.rc". This is also independent of the selection of "Resource compiler to use" option since I have everything the same after selection of "Windows SDK Resource Compiler" instead of brcc32.exe. Also, when I try additional RC compiler options (like "-16" to produce 16-bit RES file or "-32" as default), this makes nothing new. However, if I use {$R MyProject.rc, MyProject.RES}, the result is exactly as in the first way (i.e. when I use RES file).

 

And from this point I am really blunted what was wrong in my attempts. As I said before, the compilation by brcc32 itself resulted in a readable RES file so I would expect that the problem is not with this file or its content.

 

I would appreciate for any help!

Share this post


Link to post

Post your RES file.

The fact that PEResourceExplorer can read it is no guarantee that it is correct.

 

You might also try using the SDK resource compiler instead of brcc32 (which has known limitations). You can select the RC compiler to use in the project options.

Share this post


Link to post
23 hours ago, Anders Melander said:

Post your RES file.

The fact that PEResourceExplorer can read it is no guarantee that it is correct.

 

You might also try using the SDK resource compiler instead of brcc32 (which has known limitations). You can select the RC compiler to use in the project options.

Thank you for feedback, plase find the RES file attached here.

 

However, as I made it using brcc32.exe from the shell of Delphi 10.4, I doubt that it can be damaged... And I have also tried another RC compiler, with no success.

 

Thanks in advance!

EqapAll6.RES

Share this post


Link to post

I can confirm that there are no errors in the res file.

 

On 2/2/2023 at 11:27 AM, lookin030577 said:

First, before the compilation I simply replaced my new empty RES file (appeared automatically in my project folder) with the old one. The compiler passed everything without warnings but the execution has raised an error about "a resource not found" when attempting to load a resource by execution of code lines. This time, the old RES file is replaced back to the new empty one. 

This is because Delphi will generate the "default" res file thus overwriting your custom one. The default res file is the one referenced by the directive "{$R *.res}".

 

I suggest you name your res file so it doesn't conflict with the default project res file. I also suggest you either remove the MAINICON icon from your res file or delete the "{$R *.res}" directive. Otherwise, you will get a duplicate resource warning (because the project res file also contains a MAINICON icon) and the linker will have to discard one of them.

 

With regard to "RLINK32: Unsupported 16bit resource in file" it could be many different things that cause this and without knowing exactly what your rc file looks like it's impossible to guess which one it is. You could try making sure that the rc file is in UTF-8 format.

Share this post


Link to post

There is another possible cause:

Some of your D6 .dfm files may be saved in binary format, and not as a text .dfm.

In D6, open the .dfm files and see if you can view / save them as text.

Share this post


Link to post
1 hour ago, Anders Melander said:

I can confirm that there are no errors in the res file.

 

This is because Delphi will generate the "default" res file thus overwriting your custom one. The default res file is the one referenced by the directive "{$R *.res}".

 

I suggest you name your res file so it doesn't conflict with the default project res file. I also suggest you either remove the MAINICON icon from your res file or delete the "{$R *.res}" directive. Otherwise, you will get a duplicate resource warning (because the project res file also contains a MAINICON icon) and the linker will have to discard one of them.

 

With regard to "RLINK32: Unsupported 16bit resource in file" it could be many different things that cause this and without knowing exactly what your rc file looks like it's impossible to guess which one it is. You could try making sure that the rc file is in UTF-8 format.

Thank you for the suggestions, I will try. The linker says me indeed about the duplication in the case of using RES file directive, but it does not prevent successful compilation. The error (resource is not found) is only appearing if I try to load a resource in run-time. The composition of RC file is in its simplest form (I made it in Notepad.exe) and does not contain any special symbol:

 

  MAINICON ICON "EqapAll6.ico"
  ACQFILESIGN BITMAP "acq.bmp" 

 

and so on. 

Share this post


Link to post
29 minutes ago, Lars Fosdal said:

There is another possible cause:

Some of your D6 .dfm files may be saved in binary format, and not as a text .dfm.

In D6, open the .dfm files and see if you can view / save them as text.

Thank you for this notion, I have already noticed in the web that this problem can exist in some older projects. But in my case it is definitely not a source of problem because the compilation and running is OK if I do not include RES directive in my compilation. 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×