Meson构建系统学习

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
**********
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值