Link problem with CPP on Windows with VS 2015 Community

Hello,

I’m new to Gradle and I’m playing with the cpp_gradle example which works great on Linux but I can’t get it to link on Windows 7. I’ve added the workaround for the CRT issue and I’ve gotten the hello.dll library to compile and link ok and the main compiles but fails to link because it is trying to link against a hello.lib file that does not exist.

My build.gradle is as follows:
apply plugin: ‘cpp’

def VS_2015_INCLUDE_DIR = "C:/Program Files (x86)/Windows Kits/10/Include/10.0.10150.0/ucrt"
def VS_2015_LIB_DIR = "C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10150.0/ucrt"

model {
   buildTypes {
      debug
      release
   }

   platforms {
      x86 {
         architecture "x86"
      }
      x64 {
         architecture "x86_64"
      }
      itanium {
         architecture "ia-64"
      }
   }

   flavors {
      community
      enterprise
   }

   components {
      hello (NativeLibrarySpec) {
         binaries.all {
            if (targetPlatform.operatingSystem.windows) {
               cppCompiler.args "-I" + VS_2015_INCLUDE_DIR
               if (targetPlatform.architecture.name == "x86") {
                  linker.args "/LIBPATH:" + VS_2015_LIB_DIR + "/x86"
               }
               else if (targetPlatform.architecture.name == "x86_64"
                    ||  targetPlatform.architecture.name == "amd64") {
                  linker.args "/LIBPATH:" + VS_2015_LIB_DIR + "/x64"
               }              
            }
         }
      }
      main (NativeExecutableSpec) {
         binaries.all
         {
         if (targetPlatform.operatingSystem.windows) {
            cppCompiler.args "-I" + VS_2015_INCLUDE_DIR
            if (targetPlatform.architecture.name == "x86") {
               linker.args "/LIBPATH:" + VS_2015_LIB_DIR + "/x86"
            }
            else if (targetPlatform.architecture.name == "x86_64"
                 ||  targetPlatform.architecture.name == "amd64") {
               linker.args "/LIBPATH:" + VS_2015_LIB_DIR + "/x64"
            }              
         }
            lib library: "hello"
         }
      }
   }
}

task wrapper (type: Wrapper) {
    gradleVersion = '2.7'
}

And the options.txt file is as follows:

"/LIBPATH:C:/Program Files (x86)/Windows Kits/10/Lib/10.0.10150.0/ucrt/x86"
/OUT:E:\cpp_gradle\build\binaries\mainExecutable\debugCommunity\main.exe
/NOLOGO
"/LIBPATH:C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\lib"
"/LIBPATH:C:\Program Files (x86)\Windows Kits\8.1\Lib\winv6.3\um\x86"
E:\cpp_gradle\build\objs\mainExecutable\debugCommunity\mainCpp\alen6dm0tbfady0lxjbaf24f9\main.obj
E:\cpp_gradle\build\binaries\helloSharedLibrary\debugCommunity\hello.lib

Any ideas what I might be doing wrong? Also, is there a way to do the CRT workaround only once instead of in both the hello and main sections?


Regards
Russell