Aroma L.
Aroma L.

Reputation: 31

How to set icon(or .ico file) on executable file in linux system?

I've been trying to set icon on executable file(.exe) in linux and macOS.

what I learn is there are 3 places icon sets: on taskbar, window bar, and executable file thumbnail. I have set on taskbar and window bar, but not on exe file. (By the way, I've already done on 3 of them in windows using visual studio.)

and I might not know exact term of it, so I will show the example below: enter image description here

I guess .rc file should be in makefile. If so, I could solve it also in macOS. If not, I want to know how to set in linux and macOS too. Please let me know how to use it and set it. Thanks in advance.

p.s. I set icons on window bar and taskbar using GLFWimage and working on openGL3 & c++.

glfwSetWindowIcon(window, 1, &icon);

Upvotes: 3

Views: 3218

Answers (1)

Martin Rosenau
Martin Rosenau

Reputation: 18503

I guess .rc file should be in makefile.

While there is a "standardized" way for storing icons in Windows .exe files, there is no such method for "ELF" files (the most common executable file format under Linux).

on taskbar and window bar

The icon used by the window manager (e.g. for the task bar) is typically stored as "X11 window property". A "X11 window property" is some data assigned to a window by a program.

The program must provide the icon image as array and call the function XChangeProperty() (this is what the function glfwSetWindowIcon() indirectly does).

It is not necessary that the icon is stored in a special way (comparable to the .rc file in Windows); the program can simply store the icon in some const array or even calculate the icon image data before calling XChangeProperty().

... but not on exe file.

As I already have written, there is no "standardized" way to store icons in executable files for Linux.

Some file managers "know" certain programs and display the corresponding icons: They know that "xterm" is a terminal program, so they display the terminal icon. However, this icon is not stored inside the executable file but in the file manager: If you rename any executable file to "xterm", the terminal icon will be displayed.

There is an extension named "elfres" (it was named "elficon" some years ago) that allows adding icons to ELF executable files. The web site of that extension is found here. On the linked web site you also find a screen shot with an example - so you can check if I understood you correctly and this is what you are talking about.

Unfortunately, this is a non-standard extension. For this reason a "standard" Linux installation will not check if an executable file contains an icon and therefore not show the icon.

If you use the "elfres" method, you must install a special plug-in; otherwise the icons of executable files are not shown.

Upvotes: 1

Related Questions