macos中安装和设置ninja

1、在安装ninja的过程中需要先安装re2c(github地址:https://github.com/skvadrik/re2c):

bash 复制代码
git clone https://github.com/skvadrik/re2c.git

(也可直接下载最新的release压缩包,并解压。下载地址:https://github.com/skvadrik/re2c/releases)

打开终端,cd到re2c目录下执行:

bash 复制代码
./autogen.sh

这一步若报错:autoreconf: command not found,说明未安装automake,执行第2步安装automark;若执行成功直接执行第3步

2、通过homebrew安装automake,若未安装homebrew,先执行以下命令安装homebrew:

bash 复制代码
/bin/bash -c "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

已安装homebrew,安装automake:

bash 复制代码
brew install automake

安装libtool

bash 复制代码
brew install libtool

以上步骤完成之后,接着执行第1步

3、接着执行:

bash 复制代码
$ ./configure 
$ make -j4 && make install

4、以上3步之后,rec2就安装完成了,接下来安装ninja,执行以下命令:

bash 复制代码
git clone https://github.com/ninja-build/ninja.git && cd ninja

Python安装:

bash 复制代码
./configure.py --bootstrap

CMake安装:

bash 复制代码
cmake -Bbuild-cmake -H.

cmake --build build-cmake

最后,将可执行文件拷贝到/usr/bin/(或/usr/local/bin)目录下:

bash 复制代码
cp ninja /usr/bin/   #使用sudo不能复制到/usr/bin/目录下,可使用下面的方法
或
ln -s /Users/mac/code/ninja/ninja /usr/local/bin/ninja

注:在/.zshrc或/.bash_profile文件中,设置alias=/Users/mac/code/ninja/ninja,没起作用。

相关推荐
Bigger7 小时前
Tauri(21)——窗口缩放后的”失焦惊魂”,游戏控制权丢失了
前端·macos·app
Bigger8 小时前
Tauri (20)——为什么 NSPanel 窗口不能用官方 API 全屏?
前端·macos·app
Wcowin18 小时前
Mac Shell 环境优化指南
macos·职场和发展·蓝桥杯
止礼19 小时前
FFmpeg8.0.1 Mac环境 CMake本地调试配置
macos·ffmpeg
sean90819 小时前
Colima 下 docker pull 失败自查流程
macos·docker·容器·colima
denggun123452 天前
卡顿监测原理
macos·ios·xcode
Sheffi662 天前
iOS 触摸事件完整传递链路:Hit-Test 全流程深度解析
macos·ios·cocoa
ChineHe2 天前
Gin框架入门篇002_第一个Gin服务
macos·xcode·gin
Roc.Chang2 天前
解决 macOS 26.1 The application “xxxx” can’t be opened. 问题
macos
赶路人儿2 天前
从intel mac迁移到M3后软件的兼容性
macos