Thursday, December 18, 2014

Building Protobuf on OSX

I wanted to play with protocol buffers on my local OSX machine but set up isn't so straight forward so I thought that I'd document the steps.

Step 1:  Get the build tools.

If you have all the build tools installed then skip ahead, but on the particular machine that I was using it didn't.   So I had to do the following:

Install Xcode command line tools

xcode-select --install

Install the GNU build tools (autoconf, automake, libtool):

curl -OL
tar -xzf autoconf-latest.tar.gz 
cd autoconf-2.69./configure && make && sudo make install 
curl -OL
tar -xzf libtool-2.4.2.tar.gz 
cd libtool-2.4.2./configure && make && sudo make install 
curl -OL
tar -xzf automake-1.14.tar.gz
cd automake-1.14 
./configure && make && sudo make install

Alternatively you can use Homebrew or MacPorts to get the packages.

Step 2: Get the Protocol Buffer Compiler and Build It

git clone git:// 
cd protobuf 
sudo make install

Since I wanted to use protocol buffer in Go, I have to install the Go plugin for the compiler:

go get -u
go get -u 

The system can now compile your proto files to let you use it in your code:

protoc --go_out=.