Reputation: 57
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
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
Reputation: 9835
/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:
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..bash_profile
and making the command available for use.which readelf
to ensure that your desired command is found & reachableEnjoy ๐
Upvotes: 1
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