GCC on Windows: Set “Description” field of C executable?

泪湿孤枕 提交于 2019-12-04 10:57:15

That information is taken from a Version Info resource. Windows executables can contain resource files embedded in them. Normally, with Microsoft Visual Studio, you create a resource script (.rc file), and the Visual Studio resource compiler will compile it into the executable for you. VS also contains a nice visual resource editor for editing the various types of resources (string tables, icons, bitmaps, cursors, menus, dialog boxes, version info, etc.).

With GCC, you'll have to create the resource script yourself. See MSDN for more info on the VERSIONINFO resource type. Once you've created a valid resource script, you can use windres to compile it into an object file (.o). This page has a good example of how to do that. Finally, once you have an object file, you just link it in with the rest of your object files as usual.

Yes, you need a resource file.

  1. For info about writing your own .rc resource file (including your FileDescription field), see: MSDN: VERSIONINFO Resource

  2. To link a resource file using gcc, see: "Setting icons [or any resource for Windows programs with gcc":

The Windows versions of gcc (MinGW, Cygwin) come with a tool called "windres". This will compile resource files into object files for you to include at the linking stage. As a simple example, to compile the file 'chocolate-doom-res.rc':

windres chocolate-doom-res.rc chocolate-doom-res.o

This gives you a '.o' that you can conveniently drop into your build, eg.

gcc other.o files.o etc.o chocolate-doom-res.o -o chocolate-doom.exe
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!