我想在我的cpp可执行文件(.exe)中添加一个图标。我似乎找不到任何有关它的信息。我在Gradle中使用cpp插件。我在项目目录中有一个名为etc的文件夹,其中带有一个图标。 我已经看到过如何在Visual Studio或Eclipse中做到这一点的文章,但是我想在Gradle中做到这一点,因此在构建时,带有图标的可执行文件已经存在。
我的代码:
apply plugin: 'cpp'
model {
components {
main(NativeExecutableSpec) {
sources {
cpp {
source {
srcDirs "${projectDir}\\source"
include "**\\*.cpp"
}
exportedHeaders {
srcDirs "${projectDir}\\source"
include "**\\*.h"
}
}
}
}
}
platforms {
windows_x86 {
operatingSystem "windows"
architecture "x86"
}
}
repositories {
libs(PrebuiltLibraries) {
def libDir = "${projectDir}\\lib\\"
ms {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(libDir + "ms.dll")
sharedLibraryLinkFile = file(libDir + "ms.lib")
}
}
conf {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(libDir + "conf.dll")
sharedLibraryLinkFile = file(libDir + "conf.lib")
}
}
supp {
binaries.withType(SharedLibraryBinary) {
sharedLibraryFile = file(libDir + "supp.dll")
sharedLibraryLinkFile = file(libDir + "supp.lib")
}
}
}
}
toolChains {
mingw_x86(Gcc) {
path "C:\\MinGW\\bin"
eachPlatform() {
cCompiler.executable "gcc"
cppCompiler.executable "g++"
linker.executable "g++"
assembler.executable "as"
staticLibArchiver.executable "ar"
}
target("windows_x86")
}
}
binaries {
withType(NativeExecutableBinarySpec) {
if (toolChain in Gcc) {
cppCompiler.args "-m32"
cppCompiler.args "-c"
cppCompiler.args "-w"
cppCompiler.args "-I${projectDir}\\include"
cppCompiler.args "-std=c++11"
cppCompiler.args "-MMD"
cppCompiler.args "-MP"
linker.args "-Llib"
lib library: "ms", linkage: "shared"
lib library: "conf", linkage: "shared"
lib library: "supp", linkage: "shared"
}
}
}
}