Cannot generate vs2017 project file with msys2

I clone the project from gitlab, from README.win32 I know we can generate vs2017 project file.
I use MSYS2 (MingW-32bit) to install all dependencies like cairo, glib, fribidi, etc, and from MinGW-32bit shell I can compile the project successfully as below:
meson setup build
cd build
meson compile
everything is ok. However when I want to generate vs2017 project file like below from Mingw-32bit: meson setup buildvs --backend=vs2017 the setup failed as below:
The Meson build system
Version: 0.57.1
Source dir: D:/gtk/pango
Build dir: D:/gtk/pango/buildvs
Build type: native build
Project name: pango
Project version: 1.48.4
C compiler for the host machine: ccache cc (gcc 10.2.0 “cc (Rev3, Built by MSYS2 project) 10.2.0”)
C linker for the host machine: cc ld.bfd 2.35
C++ compiler for the host machine: ccache c++ (gcc 10.2.0 “c++ (Rev3, Built by MSYS2 project) 10.2.0”)
C++ linker for the host machine: c++ ld.bfd 2.35
Host machine cpu family: x86
Host machine cpu: x86
Compiler for C supports arguments -Wimplicit-function-declaration: YES
Compiler for C supports arguments -Wstrict-prototypes: YES
Compiler for C supports arguments -Wmissing-prototypes: YES
Compiler for C supports arguments -Wnested-externs: YES
Compiler for C supports arguments -Wold-style-definition: YES
Compiler for C supports arguments -Wno-int-conversion: YES
Compiler for C supports arguments -Wno-discarded-qualifiers: YES
Compiler for C supports arguments -Werror=implicit: YES
Compiler for C supports arguments -Werror=pointer-to-int-cast: YES
Compiler for C supports arguments -fno-strict-aliasing: YES
Compiler for C supports arguments -Wpointer-arith: YES
Compiler for C supports arguments -Wmissing-declarations: YES
Compiler for C supports arguments -Wformat=2: YES
Compiler for C supports arguments -Wformat-nonliteral: YES
Compiler for C supports arguments -Wformat-security: YES
Compiler for C supports arguments -Wunused: YES
Compiler for C supports arguments -Wcast-align: YES
Compiler for C supports arguments -Wmissing-noreturn: YES
Compiler for C supports arguments -Wmissing-format-attribute: YES
Compiler for C supports arguments -Wmissing-include-dirs: YES
Compiler for C supports arguments -Wlogical-op: YES
Compiler for C supports arguments -Wno-uninitialized: YES
Compiler for C supports arguments -Wno-shadow: YES
Compiler for C supports arguments -Werror=implicit-fallthrough: YES
Compiler for C supports arguments -Werror=nonnull: YES
Compiler for C supports arguments -Werror=init-self: YES
Compiler for C supports arguments -Werror=main: YES
Compiler for C supports arguments -Werror=missing-braces: YES
Compiler for C supports arguments -Werror=sequence-point: YES
Compiler for C supports arguments -Werror=return-type: YES
Compiler for C supports arguments -Werror=trigraphs: YES
Compiler for C supports arguments -Werror=array-bounds: YES
Compiler for C supports arguments -Werror=write-strings: YES
Compiler for C supports arguments -Werror=address: YES
Compiler for C supports arguments -Werror=int-to-pointer-cast: YES
Compiler for C supports arguments -Werror=empty-body: YES
Compiler for C supports arguments -Werror=write-strings: YES (cached)
Compiler for C supports arguments -Werror=unused-but-set-variable: YES
Compiler for C supports arguments -Wundef: YES
Compiler for C supports arguments -mms-bitfields: YES
Compiler for C supports arguments -fvisibility=hidden: YES
Checking for function “sysconf” : NO
Checking for function “getpagesize” : YES
Checking for function “flockfile” : NO
Checking for function “strtok_r” : YES
Has header “unistd.h” : YES
Has header “sys/mman.h” : NO
Has header “dirent.h” : YES
Message: Enabling various debug infrastructure
Library m found: YES
Found pkg-config: C:\msys64\mingw32\bin/pkg-config.EXE (0.29.2)
Run-time dependency glib-2.0 found: YES 2.64.5
Run-time dependency gobject-2.0 found: YES 2.64.5
Run-time dependency gio-2.0 found: YES 2.64.5
Run-time dependency fribidi found: YES 1.0.10
Run-time dependency libthai found: YES 0.1.28
Checking for function “th_brk_find_breaks” with dependency libthai: YES
Run-time dependency harfbuzz found: YES 2.7.2
Run-time dependency fontconfig found: YES 2.13.92
Message: fontconfig has FcWeightFromOpenTypeDouble: YES
Run-time dependency freetype2 found: YES 23.2.17
Found CMake: C:\msys64\mingw32\bin/cmake.EXE (3.17.3)
Run-time dependency xft found: NO (tried pkgconfig and cmake)
Run-time dependency cairo found: YES 1.16.0
Run-time dependency cairo-ft found: YES 1.16.0
Run-time dependency cairo-win32 found: YES 1.16.0
Run-time dependency cairo-quartz found: NO (tried pkgconfig and cmake)
Run-time dependency cairo-png found: YES 1.16.0
Run-time dependency cairo-ps found: YES 1.16.0
Run-time dependency cairo-pdf found: YES 1.16.0
Run-time dependency cairo-xlib found: NO (tried pkgconfig and cmake)
Dependency sysprof-capture-4 skipped: feature sysprof disabled
Run-time dependency gi-docgen found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency gi-docgen

|Executing subproject gi-docgen method meson
|
|Project name: gi-docgen
|Project version: 2021.3
|Program python3 (jinja2, markdown, markupsafe, pygments, toml, typogrify) found: YES (C:\msys64\mingw32\bin/python3.EXE) modules: jinja2, markdown, markupsafe, pygments, toml, typogrify
|Program gi-docgen.py found: YES (C:/msys64/mingw32/bin/python.exe D:/gtk/pango/subprojects/gi-docgen/gi-docgen.py)
|Configuring gi-docgen.pc using configuration
|Build targets in project: 0
|Subproject gi-docgen finished.

Dependency gi-docgen from subproject subprojects/gi-docgen found: YES 2021.3
Configuring config.h using configuration
Configuring pango-features.h using configuration
Program glib-mkenums found: YES (C:\msys64\mingw32\bin/glib-mkenums.EXE)
Configuring pango.rc using configuration
Windows resource compiler: GNU windres (GNU Binutils) 2.35
Program g-ir-scanner found: NO
Configuring pangoft2.rc using configuration
Library gdi32 found: YES
Configuring pangowin32.rc using configuration
Configuring pangocairo.rc using configuration
Library gdi32 found: YES
Program help2man found: NO
Program build-aux/meson/dist-docs.py found: YES (C:/msys64/mingw32/bin/python.exe D:/gtk/pango/build-aux/meson/dist-docs.py)
Build targets in project: 55

pango 1.48.4

  Subprojects
    gi-docgen: YES

Traceback (most recent call last):
  File "C:/msys64/mingw32/lib/python3.8/site-packages/mesonbuild/mesonmain.py", line 132, in run
    return options.run_func(options)
  File "C:/msys64/mingw32/lib/python3.8/site-packages/mesonbuild/msetup.py", line 275, in run
    app.generate()
  File "C:/msys64/mingw32/lib/python3.8/site-packages/mesonbuild/msetup.py", line 183, in generate
    self._generate(env)
  File "C:/msys64/mingw32/lib/python3.8/site-packages/mesonbuild/msetup.py", line 245, in _generate
    intr.backend.generate()
  File "C:/msys64/mingw32/lib/python3.8/site-packages/mesonbuild/backend/vs2010backend.py", line 192, in generate
    projlist = self.generate_projects()
  File "C:/msys64/mingw32/lib/python3.8/site-packages/mesonbuild/backend/vs2010backend.py", line 425, in generate_projects
    self.gen_vcxproj(target, str(projfile_path), proj_uuid)
  File "C:/msys64/mingw32/lib/python3.8/site-packages/mesonbuild/backend/vs2010backend.py", line 779, in gen_vcxproj
    vscrt_type = self.environment.coredata.options[OptionKey('b_vscrt')]
KeyError: OptionKey('b_vscrt', '', <MachineChoice.HOST: 1>, None)

That means that the commands should be issued inside visual studio command line, but when I use “x64 native tools command prompt…” to issue such commands, the setup still failed (I think missing mingw environment), could someone please help me how to generate vs2017 or vs2019 project files, thanks!

You need to run meson from inside VS toolchain cmd, you don’t need anything from mingw/msys for the msvc build.

Hi alatiera, Thank you for your help, I run meson from x86 native tools prompt for vs 2017, but also failed as below (cause those envvars not set correctly which installed with mingw? or should I use vcpkg?):
The Meson build system
Version: 0.55.3
Source dir: D:\gtk\pango
Build dir: D:\gtk\pango\buildvs
Build type: native build
Project name: pango
Project version: 1.48.4
C compiler for the host machine: cl (msvc 19.16.27043)
C linker for the host machine: link link 14.16.27043.0
C++ compiler for the host machine: cl (msvc 19.16.27043)
C++ linker for the host machine: link link 14.16.27043.0
Host machine cpu family: x86
Host machine cpu: x86
Compiler for C supports arguments -FImsvc_recommended_pragmas.h: NO
Compiler for C supports arguments -utf-8: YES
Compiler for C supports arguments -FImsvc_recommended_pragmas.h: NO (cached)
Compiler for C supports arguments -utf-8: YES (cached)
Checking for function “sysconf” : NO
Checking for function “getpagesize” : NO
Checking for function “flockfile” : NO
Checking for function “strtok_r” : NO
Has header “unistd.h” : NO
Has header “sys/mman.h” : NO
Has header “dirent.h” : NO
Message: Enabling various debug infrastructure
Library m found: NO
Found pkg-config: C:\msys64\mingw32\bin\pkg-config.EXE (0.29.2)
Run-time dependency glib-2.0 found: YES 2.64.5
Run-time dependency gobject-2.0 found: YES 2.64.5
Run-time dependency gio-2.0 found: YES 2.64.5
Run-time dependency fribidi found: YES 1.0.10
Run-time dependency libthai found: YES 0.1.28
Checking for function “th_brk_find_breaks” with dependency libthai: NO
Run-time dependency harfbuzz found: YES 2.7.2
Run-time dependency fontconfig found: YES 2.13.92
Message: fontconfig has FcWeightFromOpenTypeDouble: YES
Run-time dependency freetype2 found: YES 23.2.17
Found CMake: C:\Program Files (x86)\CMake\bin\cmake.EXE (3.19.0)
Run-time dependency xft found: NO (tried pkgconfig and cmake)
Run-time dependency cairo found: YES 1.16.0
Run-time dependency cairo-ft found: YES 1.16.0
Run-time dependency cairo-win32 found: YES 1.16.0
Run-time dependency cairo-quartz found: NO (tried pkgconfig and cmake)
Run-time dependency cairo-png found: YES 1.16.0
Run-time dependency cairo-ps found: YES 1.16.0
Run-time dependency cairo-pdf found: YES 1.16.0
Run-time dependency cairo-xlib found: NO (tried pkgconfig and cmake)
Dependency sysprof-capture-4 skipped: feature sysprof disabled
Run-time dependency gi-docgen found: NO (tried pkgconfig and cmake)
Looking for a fallback subproject for the dependency gi-docgen

|Executing subproject gi-docgen method meson
|
|Project name: gi-docgen
|Project version: 2021.3
|Program python3 (jinja2, markdown, markupsafe, pygments, toml, typogrify) found: YES (C:\msys64\mingw32\bin\python3.EXE) modules: jinja2, markdown, markupsafe, pygments, toml, typogrify
|Program gi-docgen.py found: YES
|Configuring gi-docgen.pc using configuration
|Build targets in project: 0
|Subproject gi-docgen finished.

Dependency gi-docgen from subproject subprojects\gi-docgen found: YES 2021.3
Configuring config.h using configuration
Configuring pango-features.h using configuration
Program glib-mkenums found: YES
Configuring pango.rc using configuration
Windows resource compiler: Microsoft (R) Windows (R) Resource Compiler Version 10.0.10011.16384
Program g-ir-scanner found: NO
Configuring pangoft2.rc using configuration
Library gdi32 found: YES
Configuring pangowin32.rc using configuration
Configuring pangocairo.rc using configuration
Library gdi32 found: YES
Program help2man found: NO
Program build-aux/meson/dist-docs.py found: YES (C:\Meson\meson.exe runpython D:\gtk\pango\build-aux/meson/dist-docs.py)
Build targets in project: 55

pango 1.48.4

  Subprojects
    gi-docgen: YES

Traceback (most recent call last):
  File "mesonbuild\mesonmain.py", line 140, in run
  File "mesonbuild\msetup.py", line 245, in run
  File "mesonbuild\msetup.py", line 159, in generate
  File "mesonbuild\msetup.py", line 215, in _generate
  File "mesonbuild\backend\vs2010backend.py", line 186, in generate
  File "mesonbuild\backend\vs2010backend.py", line 420, in generate_projects
  File "mesonbuild\backend\vs2010backend.py", line 762, in gen_vcxproj
  File "mesonbuild\backend\vs2010backend.py", line 568, in gen_custom_target_vcxproj
  File "mesonbuild\backend\backends.py", line 405, in as_meson_exe_cmdline
  File "ntpath.py", line 216, in basename
  File "ntpath.py", line 185, in split
TypeError: expected str, bytes or os.PathLike object, not File

as README.win32 said: (With Visual Studio, set the INCLUDE, LIB, PATH and PKG_CONFIG_PATH envvars as
needed before running the following in a Visual Studio command prompt)
python $(PATH_TO_meson.py) $(PATH_TO_SRC) --buildtype=$(buildtype) --prefix=$(PREFIX)

but without .sln created I cannot set INCLUDE, LIB, etc, is there some detailed guide to setup vs? Thanks.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.