Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Help Request] How to build with VS2022 Build Tools only and what is the minimum required components for the project to successfully compile? #30

Open
vavavr00m opened this issue Jun 21, 2024 · 5 comments

Comments

@vavavr00m
Copy link
Contributor

OS: Windows 11 Pro

I cobbled up a batch script that generates the key automatically last year and it still works as of today, however, with the xz utils incident several months ago, I wanna be on the safe side and have the script eventually be able to build the KG from source automatically without installing the entire Visual Studio. I'm no developer, just casually learning how to write batch script; it's a bit of a struggle for me to figure it out.

  1. Downloaded source zip and extracted to C:

  2. Downloaded hMSBuild.bat and moved it to C:\Windows

  3. Installed VS2022 Build Tools along + some per this issue for it to stop throwing an error "vcpkg install error:in triplet x64-windows: Unable to find a valid Visual Studio instance Could not locate a complete Visual Studio instance"

> winget install Microsoft.VisualStudio.2022.BuildTools --silent --override "--wait --quiet --add ProductLang En-us --add Microsoft.VisualStudio.Component.VC.Tools.x86.x64 --add Microsoft.VisualStudio.Component.Windows10SDK --add Microsoft.VisualStudio.Component.Windows11SDK --add Microsoft.VisualStudio.Workload.NativeDesktop --includeRecommended"
  1. Rebooted

  2. Installed git

  3. Installed vcpkg

> git clone https://github.com/microsoft/vcpkg
> .\vcpkg\bootstrap-vcpkg.bat
  1. Installed mpir
.\vcpkg\vcpkg install mpir --triplet=x64-windows
  1. Not sure what this does but ran it anyway
> vcpkg integrate install
  1. Go to the extracted files
> cd C:\winrar-keygen-master
  1. Ran:
> hmsbuild winrar-keygen.sln

Build fails. See log below. What am I doing wrong? How can I simplify the process and ensure that only the necessary stuff are installed?

hMSBuild: "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\MSBuild\Current\Bin\amd64\MSBuild.exe"
MSBuild version 17.10.4+10fbfbf2e for .NET Framework
Build started 6/21/2024 12:16:07 PM.

Project "C:\winrar-keygen-master\winrar-keygen.sln" on node 1 (default targets).
ValidateSolutionConfiguration:
  Building solution configuration "Debug|x64".
Project "C:\winrar-keygen-master\winrar-keygen.sln" (1) is building "C:\winrar-keygen-master\winrar-keygen.vcxproj" (2)
 on node 1 (default targets).
PrepareForBuild:
  Creating directory "C:\winrar-keygen-master\obj\x64-Debug\".
  Structured output is enabled. The formatting of compiler diagnostics will reflect the error hierarchy. See https://ak
  a.ms/cpp/structured-output for more details.
  Creating directory "C:\winrar-keygen-master\bin\x64-Debug\".
  Creating directory "C:\winrar-keygen-master\obj\x64-Debug\winrar-keygen.tlog\".
InitializeBuildStatus:
  Creating "C:\winrar-keygen-master\obj\x64-Debug\winrar-keygen.tlog\unsuccessfulbuild" because "AlwaysCreate" was spec
  ified.
  Touching "C:\winrar-keygen-master\obj\x64-Debug\winrar-keygen.tlog\unsuccessfulbuild".
VcpkgTripletSelection:
  Using triplet "x64-windows-static" from "C:\Users\0\vcpkg\installed\x64-windows-static\"
  Using normalized configuration "Debug"
ClCompile:
  C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Tools\MSVC\14.40.33807\bin\HostX64\x64\CL.exe /c /I
  "C:\Users\0\vcpkg\installed\x64-windows-static\include" /ZI /JMC /nologo /W3 /WX- /diagnostics:column /sdl /Od /D _DE
  BUG /D _CONSOLE /D _UNICODE /D UNICODE /Gm- /EHsc /RTC1 /MTd /GS /fp:precise /Zc:wchar_t /Zc:forScope /Zc:inline /std
  :c++17 /permissive- /Fo"C:\winrar-keygen-master\obj\x64-Debug\\" /Fd"C:\winrar-keygen-master\obj\x64-Debug\vc143.pdb"
   /external:W3 /Gd /TP /FC /errorReport:queue /utf-8 _tmain.cpp
  _tmain.cpp
C:\winrar-keygen-master\BigInteger.hpp(4,10): error C1083: Cannot open include file: 'gmp.h': No such file or directory
 [C:\winrar-keygen-master\winrar-keygen.vcxproj]
  (compiling source file '_tmain.cpp')

Done Building Project "C:\winrar-keygen-master\winrar-keygen.vcxproj" (default targets) -- FAILED.

Done Building Project "C:\winrar-keygen-master\winrar-keygen.sln" (default targets) -- FAILED.


Build FAILED.

"C:\winrar-keygen-master\winrar-keygen.sln" (default target) (1) ->
"C:\winrar-keygen-master\winrar-keygen.vcxproj" (default target) (2) ->
(ClCompile target) ->
  C:\winrar-keygen-master\BigInteger.hpp(4,10): error C1083: Cannot open include file: 'gmp.h': No such file or directo
ry [C:\winrar-keygen-master\winrar-keygen.vcxproj]

    0 Warning(s)
    1 Error(s)
@bitcookies
Copy link
Owner

It may be a problem with the vcpkg installation, check ./vcpkg installation directory to see if the gmp.h file has been generated.

For example, does the file gmp.h exist in the following path?

./vcpkg/packages/mpir_x64-windows-static/include/gmp.h
./vcpkg/installed/x64-windows-static/include/gmp.h
./vcpkg/buildtrees/mpir/x64-windows-static/lib/x64/Release/gmp.h

@vavavr00m
Copy link
Contributor Author

vavavr00m commented Jun 22, 2024

Doesn't have the suffix -static probably because I used the command vcpkg install mpir --triplet=x64-windows instead of vcpkg install mpir:x64-windows-static.

\vcpkg\packages\mpir_x64-windows\include\gmp.h
\vcpkg\installed\x64-windows\include\gmp.h

lib folder does not exist in \vcpkg\buildtrees\mpir\x64-windows\, therefore, no gmp.h exist there

Is static necessary? Should I reinstall vcpkg or will the proj. be updated to handle such case?

@bitcookies
Copy link
Owner

I see line 21 of the log,

Using triplet "x64-windows-static" from "C:\Users\0\vcpkg\installed\x64-windows-static\"

The log shows that the project uses the x64-windows-static path, while you have installed the dynamic library (x64-windows, .\vcpkg\vcpkg install mpir --triplet=x64-windows). So, the root of the problem is the folder where the project is trying to use the static link library.

Static is not required, but the project is configured to use dynamic libraries correctly. That could be the problem, try that first.

Then you should also make sure Make sure the gmp.h file exists under C:\Users\0\vcpkg\installed\x64-windows\include.

@vavavr00m
Copy link
Contributor Author

vavavr00m commented Jun 24, 2024

Thank you. I used vcpkg install mpir:x64-windows-static and gmp.h is now in the first two directories. I'm getting an error because of a hardcoded path in line 92 of winrar-keygen.rc. Manually changing it to icon.png built the project and I can confirm the it worked perfectly for me.

One more thing, could you please outline the bare minimum components of the VS 2022 Build Tools required for this project to compile successfully? I downloaded over 2.3 GB solely for compiling. I'd prefer to have only what's necessary since it will be compiled on systems w/ limited space and/or poor connection.

@bitcookies
Copy link
Owner

Here's a copy of the Visual Studio Build Tools component catalogue, which, in addition to the necessary tools, requires Microsoft.VisualStudio.Component.VC.Tools.x86.x64.

Component ID Name Dependency type
Microsoft.Component.MSBuild MSBuild Required
Microsoft.VisualStudio.Component.Roslyn.Compiler C# and Visual Basic Roslyn compilers Required
Microsoft.VisualStudio.Component.TextTemplating Text Template Transformation Required
Microsoft.VisualStudio.Component.VC.CoreBuildTools C++ Build Tools core features Required
Microsoft.VisualStudio.Component.VC.CoreIde C++ core features Required
Microsoft.VisualStudio.Component.VC.Redist.14.Latest C++ 2022 Redistributable Update Required
Microsoft.VisualStudio.Component.Windows10SDK Windows Universal C Runtime Required
Microsoft.VisualStudio.ComponentGroup.NativeDesktop.Core C++ core desktop features Required
Microsoft.VisualStudio.Component.VC.Tools.x86.x64 MSVC v143 - VS 2022 C++ x64/x86 build tools (Latest) Recommended

Reference

  1. https://learn.microsoft.com/en-us/visualstudio/install/workload-component-id-vs-build-tools?view=vs-2022#desktop-development-with-c

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants