简体   繁体   English

MacOS 12.1 找不到我的 GNU binutils 的 brew 安装

[英]MacOS 12.1 cannot find my brew install of GNU binutils

I want to use GNU binutils to inspect an executable on MacOS 12.1.我想使用 GNU binutils 检查 MacOS 12.1 上的可执行文件。 I did a我做了一个

% brew install binutils

and it seemed to go fine.似乎 go 没问题。 First I tried just a首先我试了一个

% readelf <executable>

but was given:但给出了:

zsh: command not found: readelf

Then I tried checking on binutils itself:然后我尝试检查 binutils 本身:

% binutils -v

which gave me这给了我

zsh: command not found: binutils

I tried adding both我尝试同时添加

/usr/local/opt/binutils

and

/usr/local/Cellar/binutils

to my $PATH and restarting zsh.到我的 $PATH 并重新启动 zsh。 The filepaths were in my $PATH, and homebrew had put 'binutils' in the expected locations.文件路径在我的 $PATH 中,自制程序已将“binutils”放在预期位置。 But

% binutils -v

still gives me仍然给我

zsh: command not found: binutils

. . Has anyone gotten binutils to work on Mac?有没有人让 binutils 在 Mac 上工作? What am I missing?我错过了什么?

The path /usr/local/opt/binutils/bin should be added to your PATH environment variable.路径/usr/local/opt/binutils/bin应该添加到您的PATH环境变量中。

You probably didn't notice the output from brew install binutils :您可能没有注意到brew install binutils中的 output :

binutils is keg-only, which means it was not symlinked into /usr/local, because Apple's CLT provides the same tools. binutils 是 keg-only,这意味着它没有符号链接到 /usr/local,因为 Apple 的 CLT 提供了相同的工具。

If you need to have binutils first in your PATH, run: echo 'export PATH="/usr/local/opt/binutils/bin:$PATH"' >> /Users/ipellegrini/.bash_profile如果您需要在 PATH 中首先安装 binutils,请运行:echo 'export PATH="/usr/local/opt/binutils/bin:$PATH"' >> /Users/ipellegrini/.bash_profile

For compilers to find binutils you may need to set: export LDFLAGS="-L/usr/local/opt/binutils/lib" export CPPFLAGS="-I/usr/local/opt/binutils/include"为了让编译器找到 binutils,您可能需要设置:export LDFLAGS="-L/usr/local/opt/binutils/lib" export CPPFLAGS="-I/usr/local/opt/binutils/include"

So should be enough to:所以应该足以:

  • ⤵️ ⤵️
    run echo 'export PATH="/usr/local/opt/binutils/bin:$PATH"' >> ~/.bash_profile in order to add the bin folder to PATH , automatically, every time you open a new command-line shell.运行echo 'export PATH="/usr/local/opt/binutils/bin:$PATH"' >> ~/.bash_profile以便在每次打开新命令行时自动将bin文件夹添加到PATH shell .

  • close the current shell and open a new one, for triggering the .bash_profile and making the command available for use.关闭当前的 shell 并打开一个新的,用于触发.bash_profile并使命令可供使用。

  • run which readelf to ensure that your desired command is found & reachable运行which readelf以确保找到并可访问所需的命令

Enjoy享受

You needd to add:您需要添加:

/usr/local/opt/binutils/bin

Check if Xcode is installed or not:检查是否安装了 Xcode:

$ gcc --version

$ ruby -e "$(curl -fsSL https://raw.githubusercontent.com/Homebrew/install/master/install.sh)"

$ brew doctor

$ brew update

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM