Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

GCC on Windows: Set "Description" field of C executable?

How does one set the "Description" property of an executable? By this I mean the value displayed when you right-click an executable in Windows Explorer and it shows "Description:" with what seems to be just the name of the executable without the file extension.

I'm running GCC 3.4.5 (mingw-vista special r3) on Windows XP.

I have googled the heck out of this to no avail, but I have a feeling I might have to use a resource file with windres... am I on the right track at least?

I actually have been setting a custom name with -o, but I actually want a different one altogether.

like image 709
Wayne Koorts Avatar asked Feb 28 '09 20:02

Wayne Koorts


2 Answers

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.

like image 53
Adam Rosenfield Avatar answered Nov 04 '22 16:11

Adam Rosenfield


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
like image 9
Chris Peterson Avatar answered Nov 04 '22 16:11

Chris Peterson