简体   繁体   English

如何在mingw下从“resource.rc”生成“resource.h”

[英]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. 上下文 - 在Windows 7环境中使用mingw64 / gcc / windres来编译和构建一些简单的Windows实用程序。

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? 有没有办法让windres(或其他一些实用工具?)自动生成一个包含我在.rc文件中定义的所有资源ID的头文件?

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. 例如,我认为Visual Studio会自动从您的“resource.rc”生成匹配的“resource.h”,因此您不必手动定义所有ID号。 Is there any way of doing that in the mingw environment? 在mingw环境中有没有办法做到这一点?

You generally #define the resource ids in resource.h so you can use them in your .rc file and your C/C++ source files. 您通常会在resource.h中#define资源ID,因此您可以在.rc文件 C / C ++源文件中使用它们。

A IDE like Visual Studio will edit the .h and .rc files for you automatically. 像Visual Studio这样的IDE会自动为您编辑.h和.rc文件。

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: 如果由于某种原因您只需要一个文件并且您永远不会使用IDE来编辑资源,您可以格式化.rc文件,如下所示:

#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. 然后在C / C ++源文件中#include这个.rc文件。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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