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,没起作用。

相关推荐
阿福不是狗5 小时前
Python使用总结之Mac安装docker并配置wechaty
python·macos·docker
gen_5 小时前
mac环境下的python、pycharm和pip安装使用
python·macos·pycharm
SY.ZHOU10 小时前
Significant Location Change
macos·ios·cocoa
buyue__12 小时前
MacOS解决局域网“没有到达主机的路由 no route to host“
macos
明月看潮生1 天前
青少年编程与数学 01-011 系统软件简介 05 macOS操作系统
macos·青少年编程·操作系统·系统软件·编程与数学
Hello.Reader2 天前
Git 安装全攻略Linux、macOS、Windows 与源码编译
linux·git·macos
Hope Fancy2 天前
macOS 连接 Docker 运行 postgres,使用navicat添加并关联数据库
macos·docker·postgresql
John Song2 天前
macOS 上使用 Homebrew 安装redis-cli
数据库·redis·macos
yanjiee2 天前
编译一个Mac M系列可以用的yuview
macos