How to I add an icon to my c++ executable using Gradle?











up vote
1
down vote

favorite












I want to add an icon to my cpp executable (.exe). I can't seem to find anything regarding it. I'm using the cpp plugin in Gradle. I have a folder in the project directory called etc with an icon in it.
I have seen posts how to do it in visual studio or eclipse but I want to do it in Gradle so when I build, the executable with already have the icon.



My code:



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"
}
}
}
}









share|improve this question




























    up vote
    1
    down vote

    favorite












    I want to add an icon to my cpp executable (.exe). I can't seem to find anything regarding it. I'm using the cpp plugin in Gradle. I have a folder in the project directory called etc with an icon in it.
    I have seen posts how to do it in visual studio or eclipse but I want to do it in Gradle so when I build, the executable with already have the icon.



    My code:



    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"
    }
    }
    }
    }









    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      I want to add an icon to my cpp executable (.exe). I can't seem to find anything regarding it. I'm using the cpp plugin in Gradle. I have a folder in the project directory called etc with an icon in it.
      I have seen posts how to do it in visual studio or eclipse but I want to do it in Gradle so when I build, the executable with already have the icon.



      My code:



      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"
      }
      }
      }
      }









      share|improve this question















      I want to add an icon to my cpp executable (.exe). I can't seem to find anything regarding it. I'm using the cpp plugin in Gradle. I have a folder in the project directory called etc with an icon in it.
      I have seen posts how to do it in visual studio or eclipse but I want to do it in Gradle so when I build, the executable with already have the icon.



      My code:



      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"
      }
      }
      }
      }






      c++ windows gradle icons mingw






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 7 hours ago

























      asked 9 hours ago









      Osher Shuman

      113




      113





























          active

          oldest

          votes











          Your Answer






          StackExchange.ifUsing("editor", function () {
          StackExchange.using("externalEditor", function () {
          StackExchange.using("snippets", function () {
          StackExchange.snippets.init();
          });
          });
          }, "code-snippets");

          StackExchange.ready(function() {
          var channelOptions = {
          tags: "".split(" "),
          id: "1"
          };
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function() {
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled) {
          StackExchange.using("snippets", function() {
          createEditor();
          });
          }
          else {
          createEditor();
          }
          });

          function createEditor() {
          StackExchange.prepareEditor({
          heartbeatType: 'answer',
          convertImagesToLinks: true,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: 10,
          bindNavPrevention: true,
          postfix: "",
          imageUploader: {
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          },
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          });


          }
          });














           

          draft saved


          draft discarded


















          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203313%2fhow-to-i-add-an-icon-to-my-c-executable-using-gradle%23new-answer', 'question_page');
          }
          );

          Post as a guest





































          active

          oldest

          votes













          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes
















           

          draft saved


          draft discarded



















































           


          draft saved


          draft discarded














          StackExchange.ready(
          function () {
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53203313%2fhow-to-i-add-an-icon-to-my-c-executable-using-gradle%23new-answer', 'question_page');
          }
          );

          Post as a guest




















































































          Popular posts from this blog

          Schultheiß

          Verwaltungsgliederung Dänemarks

          Liste der Kulturdenkmale in Wilsdruff