gradle-native icon indicating copy to clipboard operation
gradle-native copied to clipboard

Gradle 4.6 Native Build Failure With Windows 10 and MSVS 2017 SDK

Open lacasseio opened this issue 6 years ago • 9 comments

@gblikas commented on Fri Apr 13 2018

Expected Behavior

A successful execution of C:/Gradle/gradle-4.6/samples/native-binaries/cpp on Windows 10 with Visual Studio 2017, and the Desktop Development With C++ properly installed. With desktop development default installed, the "Windows SDK 10.0.16299.0 for Desktop C++" is installed.

Current Behavior

Windows SDK fails to be found for native build specifications.

Context

This issue halts the ability to run and build NativeBuildSpec oriented libraries with the VisualCpp toolchain parameters. Seems like after the Windows 10 SDK for C++ development was properly installed, execution of vswhere.exe -all -format json showed a valid SDK directory, however, Gradle was not detecting it. Likewise, the call to vswhere.exe -all -legacy -format json showed no additional fields under "properties", which I believe is what Gradle is parsing.

Steps to Reproduce (for bugs)

Hypothetically, a fresh installation of Visual Studio 2017 Community Edition, select the "Desktop Development With C++" and manually install Gradle, according to their installation page. Afterward, navigate to the sample cpp directory for native plugin building (C:/Gradle/gradle-4.6/samples/native-binaries/cpp), and try any Gradle command associated with building the NativeBuildSpec-- e.g. gradle components.

Your Environment

  • Windows 10 x64
  • Visual Studio 2017 Community
  • Desktop Development with C++ installed-- default "un-modified".
  • Universal Windows Platform Development
  • .Net Desktop Development

Purposed Solution:

After installing, the following additional components for C++ development, and re-booting, Gradle was able to build NativeBuildSpec(s):

  • C++/CLI Support
  • Windows 10 SDK (10.0.15063) for Desktop C++
  • VC++ 2015.3 v140 toolset for desktop After doing so, a call to vswhere.exe -all -legacy -format json shows fields inside of the "properties" key, which points (obviously) to the VC++ 2015.3 v140 toolset, I just installed. Then, I was able to successfully build the NativeBuildSpec target in the sample project(s).

lacasseio avatar Apr 16 '18 13:04 lacasseio

@lacasseio Thanks for moving this to the appropriate board. Was the issue reproducible?

Also, how does this native-build repository work? It seems like there is no source code, yet there is a separate project/repo page?

gblikas avatar Apr 16 '18 18:04 gblikas

The intention is to eventually develop the native support in Gradle as separate plugins (that may be delivered inside the Gradle distribution like they are now), but currently, we just have a separate repository with issues.

big-guy avatar Apr 16 '18 18:04 big-guy

@gblikas Could you provide the output from vswhere.exe -all -legacy -format json?

big-guy avatar Apr 16 '18 20:04 big-guy

I've also have seen similar issue on my VS Build Tools installation (same as #617). I've explicitly set path to VS, but after it gradle was not able to detect Windows 10 as correct SDK. I've got next message in debug log:

19:26:30.017 [DEBUG] [org.gradle.nativeplatform.toolchain.internal.msvcpp.LegacyWindowsSdkLocator] Could not find Windows resource compiler in system path.
19:26:30.022 [DEBUG] [org.gradle.nativeplatform.toolchain.internal.msvcpp.AbstractWindowsKitComponentLocator] Ignoring candidate directory C:\Program Files (x86)\Windows Kits\10 as it does not look like a Windows SDK installation.
19:26:30.023 [DEBUG] [org.gradle.nativeplatform.toolchain.internal.msvcpp.AbstractWindowsKitComponentLocator] Ignoring candidate directory C:\Program Files (x86)\Windows Kits\10 as it does not look like a Universal C Runtime installation.

iskiselev avatar Apr 20 '18 02:04 iskiselev

@big-guy I cannot. At this point I changed work computers, sorry.

gblikas avatar Jun 21 '18 19:06 gblikas

With VS 15.7 I don't have problems with locating Windows 10 SDK installed by Visual Studio Build Tools (I still need to provide VS path).

iskiselev avatar Jun 21 '18 20:06 iskiselev

I have the same problem as @iskiselev .

Gradle can not find the VS path of a Build Tools only installation, because it does not pass -products * to vswhere. See https://github.com/Microsoft/vswhere/issues/61.

Is there a reason why gradle does not pass -products * to vswhere?

janjoerke avatar Dec 05 '18 09:12 janjoerke

I can confirm I am still seeing this problem in with Gradle 7.5, and on Aug 5th, 2022.

I was able to create a VS\Auxiliary\Build\Microsoft.VCToolsVersion.default.txt and insert the version of the Visual Studio toolchain, currently "14.28.29333" (VS 2019) and it found the VisualCpp toolchain. Now it complains about locating the Windows SDK dir, and it looks like they've changed the file structure for the install.

Currently, Gradle is looking for rc.exe and kernel32.lib and it's located somewhere else than the bin/x86 or bin directories.

Given my trouble with the

model { 
   toolchain { 
       visualcpp(VisualCpp) { 
            installDir "path to VC install" 
            windowsSdkDir = "path to windows Sdk"
            ucrtDir = "haven't even tried this yet"
       }
   }
}

Looks to me that the gradle native cpp is largely non-functional on Windows. Anyone else beside me come to this conclusion, and Is there any plans to maintain and fix this? It's already been 3 years since the original issue was fixed.

enaess avatar Aug 05 '22 19:08 enaess

@enaess bummer, this is still an issue!

gblikas avatar Aug 08 '22 16:08 gblikas