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


边栏推荐
- Traps in the explode function in PHP
- js常用方法封装
- How to renew NPDP? Here comes the operation guide!
- Analyze the knowledge transfer and sharing spirit of maker Education
- 挖财商学院给的证券账户安全吗?可以开户吗?
- LeetCode_哈希表_困难_149. 直线上最多的点数
- MySQL InnoDB架构原理
- 珍爱网微服务底层框架演进从开源组件封装到自研
- Determine the best implementation of horizontal and vertical screens
- 实现浏览页面时校验用户是否已经完成登录的功能
猜你喜欢

Using webassembly to operate excel on the browser side

教你自己训练的pytorch模型转caffe(三)

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

Learning robots have no way to start? Let me show you the current hot research directions of robots

示波器探头对信号源阻抗的影响

PHP反序列化+MD5碰撞

Duchefa d5124 md5a medium Chinese and English instructions

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

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

Abnova丨血液总核酸纯化试剂盒预装相关说明书
随机推荐
Influence of oscilloscope probe on measurement bandwidth
Duchefa s0188 Chinese and English instructions of spectinomycin hydrochloride pentahydrate
XML建模
Influence of oscilloscope probe on signal source impedance
LeetCode: Distinct Subsequences [115]
Monorepo management methodology and dependency security
Popular science | does poor English affect the NPDP exam?
Abnova fluorescent dye 620-m streptavidin scheme
Is Kai Niu 2980 useful? Is it safe to open an account
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
100 cases of shell programming
Prior knowledge of machine learning in probability theory (Part 1)
Analyze the knowledge transfer and sharing spirit of maker Education
vant 源码解析 之深层 合并对象 深拷贝
Norgen AAV extractant box instructions (including features)
示波器探头对信号源阻抗的影响
Material design component - use bottomsheet to show extended content (II)
序列联配Sequence Alignment
When steam education enters personalized information technology courses
Abnova maxpab mouse derived polyclonal antibody solution