当前位置:网站首页>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
边栏推荐
- 教你自己训练的pytorch模型转caffe(一)
- AI automatically generates annotation documents from code
- Chemical properties and application instructions of prosci Lag3 antibody
- MySQL fully parses json/ arrays
- Phpstudy Xiaopi's MySQL Click to start and quickly flash back. It has been solved
- Simple getting started example of Web Service
- 学习机器人无从下手?带你体会当下机器人热门研究方向有哪些
- Abnova丨荧光染料 620-M 链霉亲和素方案
- PHP反序列化+MD5碰撞
- Duchefa细胞分裂素丨二氢玉米素 (DHZ)说明书
猜你喜欢
leetcode:1755. 最接近目标值的子序列和
Duchefa d5124 md5a medium Chinese and English instructions
Duchefa p1001 plant agar Chinese and English instructions
Duchefa丨低熔点琼脂糖 PPC中英文说明书
Open source SPL eliminates tens of thousands of database intermediate tables
解析五育融合之下的steam教育模式
MySQL InnoDB架构原理
学习机器人无从下手?带你体会当下机器人热门研究方向有哪些
EN 438-7建筑覆盖物装饰用层压板材产品—CE认证
Maker education infiltrating the transformation of maker spirit and culture
随机推荐
树莓派4B上ncnn转换出来的模型调用时总是崩溃(Segment Fault)的原因
LeetCode: Distinct Subsequences [115]
获取前一天的js(时间戳转换)
Careercup its 1.8 serial shift includes problems
Material design component - use bottomsheet to show extended content (II)
MySQL fully parses json/ arrays
挖财商学院给的证券账户安全吗?可以开户吗?
Écrire une interface basée sur flask
Abnova cyclosporin a monoclonal antibody and its research tools
Abnova fluorescent dye 620-m streptavidin scheme
Mathematical analysis_ Notes_ Chapter 9: curve integral and surface integral
LeetCode: Distinct Subsequences [115]
AI 从代码中自动生成注释文档
Matplotlib drawing retouching (how to form high-quality drawings, such as how to set fonts, etc.)
最长摆动序列[贪心练习]
Learning notes of SAS programming and data mining business case 19
Binary search
大二下个人发展小结
Redis唯一ID生成器的实现
实现浏览页面时校验用户是否已经完成登录的功能