zeroclaim
zeroclaim

Reputation: 57

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. I did a

% brew install binutils

and it seemed to go fine. First I tried just a

% readelf <executable>

but was given:

zsh: command not found: readelf

Then I tried checking on binutils itself:

% 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. The filepaths were in my $PATH, and homebrew had put 'binutils' in the expected locations. But

% binutils -v

still gives me

zsh: command not found: binutils

. Has anyone gotten binutils to work on Mac? What am I missing?

Upvotes: 3

Views: 5464

Answers (4)

Matthew Vasseur
Matthew Vasseur

Reputation: 1

Same error message when building micro-ROS packages with the platformio CLI for vscode, for some reason platoformio identifies all newer macos versions as being ARM machines and will search for binutils in the default ARM prefix, not the x86 prefix. Creating the expected ARM path and a symlink to the x86 prefix fixes this and will allow code to build, but will break your brew install until the ARM prefix is deleted.

Upvotes: 0

Kamafeather
Kamafeather

Reputation: 9835

The path /usr/local/opt/binutils/bin should be added to your PATH environment variable.

You probably didn't notice the output from brew install binutils:

binutils is keg-only, which means it was not symlinked into /usr/local, because Apple's CLT provides the same tools.

If you need to have binutils first in your PATH, run: 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"

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.
  • ๐Ÿ”„
    close the current shell and open a new one, for triggering the .bash_profile and making the command available for use.
  • ๐Ÿ”
    run which readelf to ensure that your desired command is found & reachable

Enjoy ๐ŸŽ‰

Upvotes: 1

Sachin
Sachin

Reputation: 1704

Check if Xcode is installed or not:

$ gcc --version

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

$ brew doctor

$ brew update

Upvotes: 0

Philippe
Philippe

Reputation: 26447

You needd to add :

/usr/local/opt/binutils/bin

Upvotes: 4

Related Questions