在 Windows 中获取介子项目的 Msys2 包

Get Msys2 package for meson project in Windows

假设我想在我的 C++ 项目中使用 msys2 中的 curl 包。

所以我在系统环境中将msys2路径添加到%Path%

然后我编写 meson.build 文件,如下所示:

project('tutorial', 'cpp')
my_dependency = dependency('curl')
executable('demo', 'main.cpp', dependencies : my_dependency)

... 并使用 meson setup builddir 设置介子,但它失败并出现以下错误:

The Meson build system
Version: 0.62.0
Source dir: C:\Users\woose\example
Build dir: C:\Users\woose\example\builddir
Build type: native build
Project name: tutorial
Project version: undefined
C++ compiler for the host machine: c++ (gcc 11.2.0 "c++ (Rev10, Built by MSYS2 project) 11.2.0")
C++ linker for the host machine: c++ ld.bfd 2.38
Host machine cpu family: x86_64
Host machine cpu: x86_64
Found pkg-config: C:\msys64\mingw64\bin\pkg-config.EXE (1.8.0)
Did not find CMake 'cmake'
Found CMake: NO
Run-time dependency curl found: NO (tried pkgconfig)

meson.build:2:0: ERROR: Dependency "curl" not found, tried pkgconfig

A full log can be found at C:\Users\woose\example\builddir\meson-logs\meson-log.txt

我该如何解决?

我修好了。另外,添加了包含目录。

project('tutorial', 'cpp')
cpp = meson.get_compiler('cpp')
my_dependency = cpp.find_library('curl', dirs: 'C:/msys64/mingw64')
cflags = include_directories('c:/msys64/mingw64/include/curl')
executable('demo', 'main.cpp', include_directories : cflags, dependencies : my_dependency)