Reputation: 3119
How do I set the icon for an executable when I'm creating the executable at the command prompt with cl.exe
?
Upvotes: 1
Views: 1375
Reputation: 938
You need to separate the compiling and linking stage for this to work.
Assuming your c file is called main.c
, you already have an icon called myicon.ico
, and you want to generate the executable program.exe
:
.rc
file, for instance, program.rc
with the following content:IDI_ICON_1 ICON "myicon.ico"
The IDI_ICON_1
is an arbitrary ID that you can use in your application via a #define
statement. But just for the application icon, you don't need to do anything.
main.obj
):cl -c main.c
program.res
):rc program.rc
link main.obj program.res -out:program.exe
The program should now appear with the icon.
Upvotes: 3