当前位置:网站首页>Add ICO icon to clion MinGW compiled EXE file
Add ICO icon to clion MinGW compiled EXE file
2022-07-05 20:59:00 【Hu Anmin】
Prepare for compilation
We generate it directly after normal compilation exe There is no icon 
So many exe The programs have personality icons, so vs and qt Is relatively simple, but in Clion How can I add it in compilation ?
Prerequisite , This machine must be configured MinGW, And the environment variables are also added
After my own research, I found , We need to create one ico.rc The files are placed in the root directory of the project , Then add some configuration information to this file
id ICON "logo.ico" // Add Icon
#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" // Support Chinese
BEGIN
VALUE "CompanyName", "*** Co., LTD. \0"
VALUE "FileDescription", " Software name \0"
VALUE "FileVersion", "1.0.0.10\0"
VALUE "ProductVersion", "1.0.0.10\0"
VALUE "LegalCopyright", " copyright (C) *** Co., LTD. \0"
VALUE "LegalTrademarks", "*** Co., LTD. \0"
VALUE "OriginalFilename", "version.exe\0"
VALUE "ProductName", " Software name \0"
VALUE "InternalName", "version.exe\0"
END
END
BLOCK "VarFileInfo"
BEGIN
VALUE "Translation", 0x804, 1200 // Language - Simplified Chinese
END
END
Fillet making , Circle making , ioc Picture making

1. compile ico.rc>ico.o
Then name the icon logo.ico Put it in the root of the project , After that, we need to ico.rc The file is compiled as ico.o
windres -i "ico.rc" -o "ico.o"

Then there are two ways , Manual packing exe And use Clion compile exe , The following picture is the project structure and main file

2. Compile to executable exe
Manually compile
Go to the root directory of the project and
gcc module/calculate/calculate.c module/str/str.c ico.o -g -o main main.c
Be careful : module/calculate/calculate.c module/str/str.c These are all main.c The dependent files of , You need to take it with you when packing , and ico.o You need to compile into exe It doesn't take effect until it's finished 
Clion compile

Then we compile , Icons and information will be added to exe It's in 
effect


Want very nice icons , have access to ps Self repair
Detailed information garbled code solution

What's the problem ? This is because windows The default is ANSI code , And what we use is UTF-8 Compilation of ico.rc file
Solution use NotePad++ take ico.rc Of documents UTF-8 Code to ANSI code , then Ctrl+s preservation 
Then follow the above tutorial , take ioc.rc Recompile to ioc.o file , Then repackage the project as .exe , The effect is as follows :

modify exe Invalid Icon
When we want to put exe Replace the icon of with another icon , Find new icons as long as they have the same name as the old icons , It will automatically become an old icon , This is because windows,ico Cache issues
terms of settlement stay cmd Just enter the command in
taskkill /im explorer.exe /f
cd /d %userprofile%\appdata\local
del iconcache.db /a
start explorer.exe
exit


边栏推荐
- Which is the best online collaboration product? Microsoft loop, notion, flowus
- Learning notes of SAS programming and data mining business case 19
- Enclosed please find. Net Maui's latest learning resources
- Material design component - use bottomsheet to show extended content (II)
- Learning robots have no way to start? Let me show you the current hot research directions of robots
- CareerCup它1.8 串移包括问题
- Is Kai Niu 2980 useful? Is it safe to open an account
- Web Service简单入门示例
- MySQL InnoDB架构原理
- 显示屏DIN 4102-1 Class B1防火测试要求
猜你喜欢

Abnova丨培养细胞总 RNA 纯化试剂盒中英文说明书

How to make ERP inventory accounts of chemical enterprises more accurate

Promouvoir le développement de l'industrie culturelle et touristique par la recherche, l'apprentissage et l'enseignement pratique du tourisme

Return to blowing marshland -- travel notes of zhailidong, founder of duanzhitang

Abbkine trakine F-actin Staining Kit (green fluorescence) scheme

Abnova total RNA Purification Kit for cultured cells Chinese and English instructions

Abnova丨血液总核酸纯化试剂盒预装相关说明书

产品好不好,谁说了算?Sonar提出分析的性能指标,帮助您轻松判断产品性能及表现

Wanglaoji pharmaceutical's public welfare activity of "caring for the most lovely people under the scorching sun" was launched in Nanjing

Abnova e (diii) (WNV) recombinant protein Chinese and English instructions
随机推荐
ClickHouse 复制粘贴多行sql语句报错
Material design component - use bottomsheet to show extended content (II)
ts 之 属性的修饰符public、private、protect
sql系列(基础)-第二章 限制和排序数据
js常用方法封装
挖财商学院给的证券账户安全吗?可以开户吗?
leetcode:1755. 最接近目标值的子序列和
Wanglaoji pharmaceutical's public welfare activity of "caring for the most lovely people under the scorching sun" was launched in Nanjing
Generics of TS
珍爱网微服务底层框架演进从开源组件封装到自研
从架构上详解技术(SLB,Redis,Mysql,Kafka,Clickhouse)的各类热点问题
Chemical properties and application instructions of prosci Lag3 antibody
Determine the best implementation of horizontal and vertical screens
ODPs next map / reduce preparation
php中explode函数存在的陷阱
vant 源码解析 之深层 合并对象 深拷贝
vant 源码解析 event.ts 事件处理 全局函数 addEventListener详解
大二下个人发展小结
2.<tag-哈希表, 字符串>补充: 剑指 Offer 50. 第一个只出现一次的字符 dbc
When a user logs in, there is often a real-time drop-down box. For example, entering an email will @qq com,@163. com,@sohu. com