0

Context - using mingw64/gcc/windres in a Windows 7 environment to compile and build some simple Windows utilities.

Is there any way to get windres (or some other utility?) to automatically generate a header file with all the resource IDs that I've defined in the .rc file?

E.g., I think Visual Studio would automatically generate a matching "resource.h" from your "resource.rc", so you wouldn't have to manually define all the ID numbers. Is there any way of doing that in the mingw environment?

David
  • 962
  • 2
  • 10
  • 29
  • So I'm not too familiar with Visual Studio, and I misunderstood what it does - it autogenerates BOTH resource.rc and resource.h from the IDE. From skimming the docs I mistakenly thought it autogenerated just the header file. If you're not using Visual Studio and manually creating an .rc file then you have to manually create a matching .h file as well. – David Jun 10 '19 at 07:42

1 Answers1

1

You generally #define the resource ids in resource.h so you can use them in your .rc file and your C/C++ source files.

A IDE like Visual Studio will edit the .h and .rc files for you automatically.

If for whatever reason you only want one file and you will never use a IDE to edit resources you can format your .rc file like this:

#define MYICON 42

#ifdef RC_INVOKED ; Or whatever macro windres defines.
MYICON ICON "42.ico"
#endif

and then #include this .rc file in your C/C++ source files.

Anders
  • 97,548
  • 12
  • 110
  • 164