meson官网
2023年1月29日13:52:01
menson环境搭建
环境准备:vmware ubuntu 18.04
1、换源 换源博客连接
2、修改配置文件
:::info
sudo mv /etc/apt/sources.list /etc/apt/sources.list.bak // 备份
sudo vim /etc/apt/sources.list // 编辑修改
:::
3、软件源更新:sudo apt-get update && apt-get upgrade
4、安装meson:sudo apt install meson
第一个meson project ->hello world
创建一个项目目录,包含一个main.c文件
#include <stdio.h>
int main()
{
printf("hello world!\n");
return 0;
}
创建Meson构建描述文件meson.build(指定文件名)
project( //项目相关描述配置
'heloworld', //项目名称
'c' // 项目目标编程语言
)
executable( // 创建一个新的可执行文件
'heloworld', // 可执行文件名称
'main.c' // 指定输入文件
)
目录结构:
:::info
tree
.
├── main.c
└── meson.build
0 directories, 2 files
:::
在meson.build目录执行
项目构建关系描述完成,接下来就需要通过调用Meson来生成构建目录及构建系统。
$ meson setup build / meson build #以下是meson构建执行后的打印
The Meson build system
Version: 0.53.2
Source dir: /home/jzhan/study/meson
Build dir: /home/jzhan/study/meson/build
Build type: native build
Project name: heloworld
Project version: undefined
C compiler for the host machine: cc (gcc 11.2.0 "cc (Ubuntu 11.2.0-7ubuntu2) 11.2.0")
C linker for the host machine: cc ld.bfd 2.37
Host machine cpu family: x86_64
Host machine cpu: x86_64
Build targets in project: 1
Found ninja-1.10.0 at /usr/bin/ninja
tree -L 1
.
├── build
├── main.c
└── meson.build
1 directory, 2 files
**********