当前位置:网站首页>Clion-MinGW编译后的exe文件添加ico图标
Clion-MinGW编译后的exe文件添加ico图标
2022-07-05 20:55:00 【胡安民】
编译前准备
我们正常直接编译后生成的exe是没有任何图标的
那么很多exe程序都是有个性图标的那么在vs和qt中是比较简单的可是在Clion编译中怎么才能添加呢?
前提条件,本机必须配置好MinGW,并且环境变量也都添加了
经过自己研究发现,我们需要创建一个ico.rc
文件放在项目的根目录, 然后给这个文件添加一些配置信息
id ICON "logo.ico" //添加图标
#include <winver.h>
VS_VERSION_INFO VERSIONINFO
FILEVERSION 1,0,0,10
PRODUCTVERSION 1,0,0,10
FILEFLAGSMASK 0x3fL
#ifdef _DEBUG
FILEFLAGS VS_FF_DEBUG
#else
FILEFLAGS 0x0L
#endif
FILEOS VOS__WINDOWS32
FILETYPE VFT_DLL
FILESUBTYPE 0x0L
BEGIN
BLOCK "StringFileInfo"
BEGIN
BLOCK "080404b0" //支持中文
BEGIN
VALUE "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"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x804, 1200 //语言-简体中文
END
END
1.编译ico.rc>ico.o
然后将图标命名为logo.ico
放在项目的根目录,之后我们需要将ico.rc文件编译为ico.o
windres -i "ico.rc" -o "ico.o"
然后有两种方式,手动打包exe和使用Clion编译exe ,下面图片是项目结构和主文件
2.编译为执行文件exe
手动编译
进入项目的根目录然后
gcc module/calculate/calculate.c module/str/str.c ico.o -g -o main main.c
注意: module/calculate/calculate.c module/str/str.c 这些都是 main.c的依赖文件,打包的时候都需要一起带上 ,而ico.o 需要编译进exe中才会生效
Clion编译
然后我们进行编译,就会将图标和信息都添加到exe中了
效果
想要非常好看的图标,可以使用ps自行修
详细信息乱码解决
这是啥问题呢? 这是因为windows默认的是ANSI码 ,而我们使用的是UTF-8编译的ico.rc文件
解决办法使用NotePad++ 将ico.rc文件的UTF-8编码转换为ANSI码 ,然后Ctrl+s
保存
之后依据上面的教程, 将ioc.rc从新编译为ioc.o文件,然后在重新打包项目为.exe
,效果如下:
修改exe图标无效
当我们想将exe的图标换成其他的图标,发现新的图标只要和旧的图标名称一样那么,自动就会变为旧的图标,这是因为windows,ico缓存的问题
解决办法 在cmd中输入下命令就行了
taskkill /im explorer.exe /f
cd /d %userprofile%\appdata\local
del iconcache.db /a
start explorer.exe
exit
边栏推荐
- 2.<tag-哈希表, 字符串>补充: 剑指 Offer 50. 第一个只出现一次的字符 dbc
- 示波器探头对测量带宽的影响
- Material design component - use bottomsheet to show extended content (II)
- How to make ERP inventory accounts of chemical enterprises more accurate
- 解析五育融合之下的steam教育模式
- 王老吉药业“关爱烈日下最可爱的人”公益活动在南京启动
- Which is the best online collaboration product? Microsoft loop, notion, flowus
- CADD course learning (7) -- Simulation of target and small molecule interaction (semi flexible docking autodock)
- Phpstudy Xiaopi's MySQL Click to start and quickly flash back. It has been solved
- Duchefa s0188 Chinese and English instructions of spectinomycin hydrochloride pentahydrate
猜你喜欢
leetcode:1755. 最接近目标值的子序列和
最长摆动序列[贪心练习]
Duchefa丨P1001植物琼脂中英文说明书
表单文本框的使用(二) 输入过滤(合成事件)
Use of thread pool
Duchefa细胞分裂素丨二氢玉米素 (DHZ)说明书
Who the final say whether the product is good or not? Sonar puts forward performance indicators for analysis to help you easily judge product performance and performance
Wanglaoji pharmaceutical's public welfare activity of "caring for the most lovely people under the scorching sun" was launched in Nanjing
教你自己训练的pytorch模型转caffe(三)
Graph embedding learning notes
随机推荐
树莓派4B上ncnn转换出来的模型调用时总是崩溃(Segment Fault)的原因
从架构上详解技术(SLB,Redis,Mysql,Kafka,Clickhouse)的各类热点问题
Abnova丨 MaxPab 小鼠源多克隆抗体解决方案
研学旅游实践教育的开展助力文旅产业发展
线程池的使用
表单文本框的使用(二) 输入过滤(合成事件)
mysql全面解析json/数组
shell编程100例
Abnova blood total nucleic acid purification kit pre installed relevant instructions
CareerCup它1.8 串移包括问题
leetcode:1139. 最大的以 1 为边界的正方形
Abnova CD81 monoclonal antibody related parameters and Applications
Interpreting the daily application functions of cooperative robots
Typhoon is coming! How to prevent typhoons on construction sites!
MySQL fully parses json/ arrays
Use of form text box (II) input filtering (synthetic event)
Go file path operation
Monorepo管理方法论和依赖安全
Abnova丨 CD81单克隆抗体相关参数和应用
The development of research tourism practical education helps the development of cultural tourism industry