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

相关推荐
大熊猫侯佩18 小时前
升级到 macOS26.5 后看视频会自动息屏的解决
macos·操作系统
磊 子20 小时前
C++ IO 流
macos·objective-c·cocoa
real_haha20 小时前
我做了一个仅有 1.3 MB 的 macOS 原生 AI 助手:AskNow
人工智能·macos
June bug1 天前
(Mac)macOS x86_64上onnxruntime==1.24.4 安装失败
macos
ACP广源盛139246256731 天前
iOS 27 开放 AI 生态@ACP#小型化扩展黄金风口,IX8008全面超越 ASM2806,铸就嵌入式 AI 扩展核心
人工智能·嵌入式硬件·macos·ios·计算机外设·objective-c·cocoa
海的辽阔2 天前
如何在MAC下安装EcomGpt模型
macos·大模型·ecomgpt
zandy10112 天前
hermes agent 安装教程 3.0:Win / Mac / Linux 全平台指南
linux·运维·macos
花开·莫之弃2 天前
Mac安装多版本jdk(jenv)
java·开发语言·macos
June bug2 天前
(Mac)torch==2.1.2 与 Python 3.12 不兼容+onnxruntime-silicon 不支持 Intel Mac
开发语言·python·macos
码农小北2 天前
MAC 配置鸿蒙(HarmonyOS) SDK 环境变量完整指南
macos·华为·harmonyos