当前位置:网站首页>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


边栏推荐
- MySQL ifnull usage function
- Abbkine BCA法 蛋白质定量试剂盒说明书
- Careercup its 1.8 serial shift includes problems
- When steam education enters personalized information technology courses
- Open source SPL eliminates tens of thousands of database intermediate tables
- 科普|英语不好对NPDP考试有影响吗 ?
- 实现浏览页面时校验用户是否已经完成登录的功能
- haas506 2.0开发教程 - 阿里云ota - pac 固件升级(仅支持2.2以上版本)
- Abnova 环孢素A单克隆抗体,及其研究工具
- 示波器探头对测量带宽的影响
猜你喜欢

Norgen AAV extractant box instructions (including features)

When steam education enters personalized information technology courses

Abnova丨DNA 标记高质量控制测试方案

浅聊我和一些编程语言的缘分

Typhoon is coming! How to prevent typhoons on construction sites!

Analysis of steam education mode under the integration of five Education

Write an interface based on flask

How to make ERP inventory accounts of chemical enterprises more accurate

PHP deserialization +md5 collision

Abnova CRISPR spcas9 polyclonal antibody protocol
随机推荐
Abbkine trakine F-actin Staining Kit (green fluorescence) scheme
学习机器人无从下手?带你体会当下机器人热门研究方向有哪些
Abnova丨 MaxPab 小鼠源多克隆抗体解决方案
手机开户股票开户安全吗?我家比较偏远,有更好的开户途径么?
Abnova丨DNA 标记高质量控制测试方案
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
EN 438-7建筑覆盖物装饰用层压板材产品—CE认证
CareerCup它1.8 串移包括问题
AITM2-0002 12s或60s垂直燃烧试验
Duchefa MS medium contains vitamin instructions
AITM 2-0003 水平燃烧试验
大二下个人发展小结
判断横竖屏的最佳实现
10000+ 代码库、3000+ 研发人员大型保险集团的研发效能提升实践
驱动壳美国测试UL 2043 符合要求有哪些?
Abnova CRISPR spcas9 polyclonal antibody protocol
The development of research tourism practical education helps the development of cultural tourism industry
PHP反序列化+MD5碰撞
2. < tag hash table, string> supplement: Sword finger offer 50 The first character DBC that appears only once
Maker education infiltrating the transformation of maker spirit and culture