编译前准备
1.编译ico.rc>ico.o
将图标放到工程目录下
新建ico.rc文件
id ICON "spoon.ico" //添加图标
#include <winver.h>
VS_VERSION_INFO VERSIONINFOFILEVERSION 1,0,0,10PRODUCTVERSION 1,0,0,10FILEFLAGSMASK 0x3fL
#ifdef _DEBUGFILEFLAGS VS_FF_DEBUG
#elseFILEFLAGS 0x0L
#endifFILEOS VOS__WINDOWS32FILETYPE VFT_DLLFILESUBTYPE 0x0LBEGINBLOCK "StringFileInfo"BEGINBLOCK "080404b0" //支持中文BEGINVALUE "CompanyName", "***有限公司\0"VALUE "FileDescription", "软件名称\0"VALUE "FileVersion", "1.0.0.10\0"VALUE "ProductVersion", "1.0.0.10\0"VALUE "LegalCopyright", "版权所有 (C) ***有限公司\0"VALUE "LegalTrademarks", "***有限公司\0"VALUE "OriginalFilename", "version.exe\0"VALUE "ProductName", "软件名称\0"VALUE "InternalName", "version.exe\0"ENDENDBLOCK "VarFileInfo"BEGINVALUE "Translation", 0x804, 1200 //语言-简体中文ENDEND
编译为ico.o文件
windres -i "ico.rc" -o "ico.o"
将ico.o文件添加到CmakeLists文件中
Clion编译后查看exe文件图标