gradle / gradle-native

The home of Gradle's support for natively compiled languages
https://blog.gradle.org/introducing-the-new-cpp-plugins
Apache License 2.0
92 stars 8 forks source link

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

Open lacasseio opened 6 years ago

lacasseio commented 6 years ago

@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

Purposed Solution:

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

gblikas commented 6 years ago

@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?

big-guy commented 6 years ago

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 commented 6 years ago

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

iskiselev commented 6 years ago

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.
gblikas commented 6 years ago

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

iskiselev commented 6 years ago

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).

janjoerke commented 5 years ago

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?

enaess commented 2 years ago

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.

gblikas commented 2 years ago

@enaess bummer, this is still an issue!