简体   繁体   中英

How to generate “resource.h” from “resource.rc” under mingw

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?

Eg, 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?

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM