php / php-sdk-binary-tools

Tool kit for building PHP under Windows
BSD 2-Clause "Simplified" License
85 stars 32 forks source link

Error - Could not determine 'vs16' directory #10

Closed JMoodyFWD closed 6 months ago

JMoodyFWD commented 6 months ago

I have Visual Studio 2022 Community on Windows 11 installed and tried following the directions, but I'm getting nowhere.

Following the instructions in this repo's readme, I tried to run phpsdk-vs16-x64.bat and I get the following output:

Could not determine 'vs16' directory

Runningvswhere from both bin\vswhere and globally both return the following output:

Visual Studio Locator version 2.6.7+91f4c1d09e [query version 3.8.2091.34612]
Copyright (C) Microsoft Corporation. All rights reserved.

instanceId: fc6b758c
installDate: 2/12/2024 9:08:10 PM
installationName: VisualStudio/17.8.6+34525.116
installationPath: C:\Program Files\Microsoft Visual Studio\2022\Community
installationVersion: 17.8.34525.116
productId: Microsoft.VisualStudio.Product.Community
productPath: C:\Program Files\Microsoft Visual Studio\2022\Community\Common7\IDE\devenv.exe
state: 4294967295
isComplete: 1
isLaunchable: 1
isPrerelease: 0
isRebootRequired: 0
displayName: Visual Studio Community 2022
description: Powerful IDE, free for students, open-source contributors, and individuals
channelId: VisualStudio.17.Release
channelUri: https://aka.ms/vs/17/release/channel
enginePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\resources\app\ServiceHub\Services\Microsoft.VisualStudio.Setup.Service
installedChannelId: VisualStudio.17.Release
installedChannelUri: https://aka.ms/vs/17/release/channel
releaseNotes: https://docs.microsoft.com/en-us/visualstudio/releases/2022/release-notes-v17.8#17.8.6
resolvedInstallationPath: C:\Program Files\Microsoft Visual Studio\2022\Community
thirdPartyNotices: https://go.microsoft.com/fwlink/?LinkId=661288
updateDate: 2024-02-13T04:08:10.8489884Z
catalog_buildBranch: d17.8
catalog_buildVersion: 17.8.34525.116
catalog_id: VisualStudio/17.8.6+34525.116
catalog_localBuild: build-lab
catalog_manifestName: VisualStudio
catalog_manifestType: installer
catalog_productDisplayVersion: 17.8.6
catalog_productLine: Dev17
catalog_productLineVersion: 2022
catalog_productMilestone: RTW
catalog_productMilestoneIsPreRelease: False
catalog_productName: Visual Studio
catalog_productPatchVersion: 6
catalog_productPreReleaseMilestoneSuffix: 1.0
catalog_productSemanticVersion: 17.8.6+34525.116
catalog_requiredEngineVersion: 3.8.2122.37638
properties_campaignId: 2030:606c0ce46951488a8fccb44e46cc1e82
properties_channelManifestId: VisualStudio.17.Release/17.8.6+34525.116
properties_nickname:
properties_setupEngineFilePath: C:\Program Files (x86)\Microsoft Visual Studio\Installer\setup.exe

If I try to run:

``bin\vswhere -nologo -version "[16,17)" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text

OR

bin\vswhere -nologo -version "[16,17)" -requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64 -property installationPath -format text

As mentioned in many issues posted here and on StackOverflow, It just returns nothing, so it seems like either I'm missing some sort of component in Visual Studio, or there is something that is lost in translation from the readme's directions that are somehow not applicable in 2024?

Any help would be appreciated.

JMoodyFWD commented 6 months ago

I uninstalled Visual Studio 2022, Installed Visual Studio 2019 and after installing the necessary components, I was able to build PHP without any issues. Self-closing for user error.

nono303 commented 6 months ago

Hi @JMoodyFWD Fyi, you can install multiple Build Tools version in Visual Studio. For example in VS2022 to have both vc15, vs16 & vs17, respectively :

"Microsoft.VisualStudio.Component.VC.v141.x86.x64",
"Microsoft.VisualStudio.Component.VC.14.29.16.11.x86.x64",
"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",

you can now init vcvarall.bat with the one you want call %PATH_VS%\VC\Auxiliary\Build\vcvarsall.bat %ARCH% -vcvars_ver=%vcvars_ver%

where vcvars_ver in:

this corresponds to this patch

diff --git a/bin/phpsdk_setshell.bat b/bin/phpsdk_setshell.bat
index f651a4e..6c291db 100644
--- a/bin/phpsdk_setshell.bat
+++ b/bin/phpsdk_setshell.bat
@@ -199,9 +199,9 @@ if "%HOST_ARCH_NAME%"=="%TARGET_ARCH_NAME%" (
    set VCVARSALL_ARCH_NAME=%HOST_ARCH_NAME%_%TARGET_ARCH_NAME%
 )
 if 15 gtr %PHP_SDK_VS_NUM% (
-   set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" !VCVARSALL_ARCH_NAME!
+   set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" !VCVARSALL_ARCH_NAME! -vcvars_ver=%vcvars_ver%
 ) else (
-   set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" !VCVARSALL_ARCH_NAME!
+   set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" !VCVARSALL_ARCH_NAME! -vcvars_ver=%vcvars_ver%
 )
 set VCVARSALL_ARCH_NAME=
JMoodyFWD commented 6 months ago

Hi @JMoodyFWD

Fyi, you can install multiple Build Tools version in Visual Studio.

For example in VS2022 to have both vc15, vs16 & vs17, respectively :


"Microsoft.VisualStudio.Component.VC.v141.x86.x64",

"Microsoft.VisualStudio.Component.VC.14.29.16.11.x86.x64",

"Microsoft.VisualStudio.Component.VC.Tools.x86.x64",

you can now init vcvarall.bat with the one you want

call %PATH_VS%\VC\Auxiliary\Build\vcvarsall.bat %ARCH% -vcvars_ver=%vcvars_ver%

where vcvars_ver in:

  • 14.16 (vc15)

  • 14.29 (vs16)

  • 14.39 (vs17 latest)]

this corresponds to this patch


diff --git a/bin/phpsdk_setshell.bat b/bin/phpsdk_setshell.bat

index f651a4e..6c291db 100644

--- a/bin/phpsdk_setshell.bat

+++ b/bin/phpsdk_setshell.bat

@@ -199,9 +199,9 @@ if "%HOST_ARCH_NAME%"=="%TARGET_ARCH_NAME%" (

  set VCVARSALL_ARCH_NAME=%HOST_ARCH_NAME%_%TARGET_ARCH_NAME%

 )

 if 15 gtr %PHP_SDK_VS_NUM% (

- set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" !VCVARSALL_ARCH_NAME!

+ set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\vcvarsall.bat" !VCVARSALL_ARCH_NAME! -vcvars_ver=%vcvars_ver%

 ) else (

- set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" !VCVARSALL_ARCH_NAME!

+ set PHP_SDK_VS_SHELL_CMD="!PHP_SDK_VC_DIR!\Auxiliary\Build\vcvarsall.bat" !VCVARSALL_ARCH_NAME! -vcvars_ver=%vcvars_ver%

 )

 set VCVARSALL_ARCH_NAME=

Very cool! Thanks for letting me know 😃