Friday, May 29, 2015

Install binutils in Mac OS

Sometimes we need to install binutils in Mac OS to do something. Please refer the sites.

Homebrew
Building a GCC 4.9 cross compiler on OS X Mavericks


I use the below steps to build binutils in OS X Yosemite.

1) Install brew.

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

2) Installing GCC.

We need GCC to compile binutils in Mac OS

brew tap homebrew/versions
brew install --enable-cxx gcc49

3) Download binutils.

Download the source code of binutils. We get binutils-2.25.tar.gz.

4) Extract binutils.

Extract the source code to the home directory. For example,

~/src/binutils-2.25

5) Set environment variables.

We can set environment variables to build binutils.

export PREFIX="$HOME/opt/cross"
export TARGET=i686-elf
export PATH="$PREFIX/bin:$PATH"

6) Build binutils

In the ~/src/binutils-2.25 directory run the below command.

../binutils-2.24/configure --target=$TARGET --prefix="$PREFIX" --disable-nls --disable-werror

make
make install

8) Check if binutils is installed.

cd ~/opt
find . -name *objdump*

The results display.

./cross/bin/i686-elf-objdump
./cross/i686-elf/bin/objdump
./cross/share/man/man1/i686-elf-objdump.1

-Count





1 comment: