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

Build error: QT dependency fails to build on Windows 10 when using VS BuildTools ("Could not find vcvarsall.bat") #780

Closed
aps9 opened this issue Jul 27, 2023 · 2 comments

Comments

@aps9
Copy link

aps9 commented Jul 27, 2023

Description

The QT dependencies fail to compile on Windows 10, when using Build Tools in place of a full Visual Studio 2022 installation.

Commit-id

88fb0c6

Build target

  1. Windows build

CI build status

  1. passing

Environment

  • OS: Windows 10
  • Python version (optional): 3.9.13
  • Qt5 version (optional): unknown, apparently I am following instructions to build QT 5 from source.
  • Compiler version (optional): Visual Studio Build Tools 2020 (this is important) -- no full edition of VS 2020 is installed.

Build commands

Steps of command lines to reproduce your error.
(Starting in folder C:\Development )

  1. python -m pip install six requests
  2. (I updated pip as python requested, but I don't believe this is relevant).
  3. git clone https://github.com/google/mozc.git
  4. cd mozc\src
  5. python build_tools/update_deps.py
  6. "C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsamd64_x86.bat"
    (Note, this is different from the line specified in the instructions for regular VC builds. It is tailored to the limited installation of BuildTools.)
  7. python build_tools/build_qt.py --release --confirm_license
    This is where it gets in trouble.

Error logs

extracting util/xkbdatagen/xkbdatagen.pro                                                                                                                                                                                                       Traceback (most recent call last):
  File "C:\Development\mozc\src\build_tools\build_qt.py", line 541, in <module>
    main()
  File "C:\Development\mozc\src\build_tools\build_qt.py", line 537, in main
    build_on_windows(args)
  File "C:\Development\mozc\src\build_tools\build_qt.py", line 437, in build_on_windows
    env = get_vs_env_vars('amd64_x86', args.vcvarsall_path)
  File "C:\Development\mozc\src\build_tools\build_qt.py", line 396, in get_vs_env_vars
    vcvarsall = get_vcvarsall(vcvarsall_path_hint)
  File "C:\Development\mozc\src\build_tools\build_qt.py", line 354, in get_vcvarsall
    raise FileNotFoundError('Could not find vcvarsall.bat')
FileNotFoundError: Could not find vcvarsall.bat

Additional context

Yes, I examined the file build_qt.py near line 354. The function get_vcvarsall searches for vcvarsall.bat in standard editions of Visual Studio, but it does not seem to have any provision for a Visual Studio BuildTools installation.

Part of the code looks like this:

  for edition in ['Community', 'Professional', 'Enterprise']:
    vcvarsall = pathlib.Path('C:\\', 'Program Files', 'Microsoft Visual Studio',
                             '2022', edition, 'VC', 'Auxiliary', 'Build',
                             'vcvarsall.bat')
    if vcvarsall.exists():
      return vcvarsall

  raise FileNotFoundError('Could not find vcvarsall.bat')

In my local copy, I added this before the raise statement, and it seemed to compile correctly after that:

  # Also check for BuildTools, which is a smaller installation.
  program_files_x86 = 'Program Files (x86)'
  edition = 'BuildTools'
  vcvarsall = pathlib.Path('C:\\', program_files_x86, 'Microsoft Visual Studio',
                           '2022', edition, 'VC', 'Auxiliary', 'Build',
                           'vcvarsall.bat')
  if vcvarsall.exists():
    return vcvarsall

The fresh VS 2020 BuildTools installation put itself in "Program Files (x86)" instead of Program Files. I don't know whether this is normal, or whether it's because I have some older installations of VS (2017 and 2019). However, in any case, the python code is not looking for a BuildTools installation.

Build instructions for Windows say that Build Tools for Visual Studio 2022 should work in place of the full installation of VS 2022:
"Build Tools for Visual Studio 2022 should also work"

This may be a small issue, but I appreciate your consideration.

@yukawa
Copy link
Collaborator

yukawa commented Jul 27, 2023

Thank you for the report.

Coincidentally we recently submitted c777896 for our internal build servers where Build Tools for Visual Studio 2022 are installed in C:\VS\VC. With that I guess it's already possible for you to work around your case without changing the source code as follow.

python build_qt.py --release --confirm_license --vcvarsall_path="C:\Program Files (x86)\Microsoft Visual Studio\2022\BuildTools\VC\Auxiliary\Build\vcvarsall.bat"

I'll also update build_qt.py so that it can also search vcvarsall.bat under Program Files (x86) as it shouldn't be a big deal anyway.

@aps9
Copy link
Author

aps9 commented Jul 28, 2023

I tried the command-line option you suggested, and it seems to work in getting past this issue.

If you are updating build_qt.py, then you might also consider adding 'BuildTools' to the list of editions.

Thank you for the update.

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