You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

如何通过Meson编译项目并指定LLVM路径生成.sln文件

编译rellume项目的Meson配置问题解决

问题场景

编译rellume项目执行meson build时,Meson无法检测到LLVM,报错如下:

G:\Programs\Soft\Coding\C\VisualStudio\Coders\rellume>meson build
The Meson build system
Version: 1.0.0
Source dir: G:\Programs\Soft\Coding\C\VisualStudio\Coders\rellume
Build dir: G:\Programs\Soft\Coding\C\VisualStudio\Coders\rellume\build
Build type: native build
Project name: rellume
Project version: undefined
C compiler for the host machine: cl (msvc 19.31.31107 "Microsoft (R) C/C++ Optimizing Compiler Version 19.31.31107 for x64")
C linker for the host machine: link link 14.31.31107.0
C++ compiler for the host machine: cl (msvc 19.31.31107 "Microsoft (R) C/C++ Optimizing Compiler Version 19.31.31107 for x64")
C++ linker for the host machine: link link 14.31.31107.0
Host machine cpu family: x86_64
Host machine cpu: x86_64
meson.build:14: WARNING: Project targets '>=0.49' but uses feature introduced in '0.52.0': include_type arg in dependency.
llvm-config found: NO need ['>=12', '<16']
Run-time dependency LLVM found: NO (tried config-tool)
meson.build:19: WARNING: Project targets '>=0.49' but uses feature introduced in '0.52.0': include_type arg in dependency.
llvm-config found: NO need ['>=12', '<16']
Run-time dependency LLVM found: NO (tried config-tool)

meson.build:17:2: ERROR: Dependency "llvm" not found, tried config-tool

A full log can be found at G:\Programs\Soft\Coding\C\VisualStudio\Coders\rellume\build\meson-logs\meson-log.txt
WARNING: Running the setup command as `meson [options]` instead of `meson setup [options]` is ambiguous and deprecated.

解决方法

1. 在Meson中指定LLVM路径

三种可行方式任选其一即可:

  • 方式一:设置环境变量
    CMD环境下执行:

    set LLVM_CONFIG=G:\path\to\llvm\bin\llvm-config.exe
    meson setup build
    

    PowerShell环境下执行:

    $env:LLVM_CONFIG = "G:\path\to\llvm\bin\llvm-config.exe"
    meson setup build
    
  • 方式二:通过--cmake-prefix-path参数指定LLVM安装路径
    利用Meson对CMake配置的支持,直接传递LLVM根路径:

    meson setup build --cmake-prefix-path=G:\path\to\llvm
    
  • 方式三:直接指定llvm-config路径
    在meson setup时通过参数明确指定:

    meson setup build -Dllvm-config="G:\path\to\llvm\bin\llvm-config.exe"
    

注意:确保LLVM版本符合项目要求的>=12, <16范围

2. 生成Visual Studio .sln文件

Meson支持直接生成VS解决方案,初始化构建目录时指定对应backend即可:

  • 生成默认版本VS解决方案:
    meson setup build --backend=vs
    
  • 指定具体VS版本(例如VS2022):
    meson setup build --backend=vs2022
    

执行完成后,build目录下会生成对应的.sln文件,直接用Visual Studio打开即可编译项目。

另外注意:原警告提示meson build写法已被弃用,推荐使用meson setup build初始化构建目录。

内容的提问来源于stack exchange,提问作者OSPFv3

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.04 10:10:32