Tuesday, January 06, 2015

Compile Google Protocol Buffers On Oracle Linux

Google has released a lot of code as open source software. Free for download and free to use under different open source licenses. One of the software packages released is protobuf, protobuf is google's data interchange format. Protocol buffers are Google's language-neutral, platform-neutral, extensible mechanism for serializing structured data – think XML, but smaller, faster, and simpler. You define how you want your data to be structured once, then you can use special generated source code to easily write and read your structured data to and from a variety of data streams and using a variety of languages – Java, C++, or Python.

When trying to compile RethinkDB on a Linux system you will notice that Protobuf is a prerequisite  and needs to be available. In general this is not an issue for most Linux distributions as you are able to download installation packages for it. However, when you do want to install it for Oracle Linux you will find that it is not available for Oracle Linux which leaves you with the source to compile which you need to compile to be able to use it.

As compiling is something which is generally not done by standard users and as Protobuf is something used primarily by developers do not expect everything to be as simple as you think. Some code hacking might be required to get the Google code working on your Oracle Linux machine.

During the first attempt I encountered a bug stating:
configure.ac:57: error: possibly undefined macro: AM_PROG_AR

After some hacking in the code it became clear that line 57 in configure.ac can be commented out when you encounter this issue. For some reason the macro is called and checked however not used in the rest of the code. After commenting out the line you can make and install the code without any issue.

Steps needed to get Protobuf working on Oracle Linux are the following:

1) Get the sourcecode from github.
$ git clone https://github.com/google/protobuf

2.a) Run autogen to automatically generate the config script
$ ./autogen.sh

2.b) If you run into the AM_PROG_AR issue open the configure.ac file and comment out the associated line

3)
run configure to prepare for make
$ ./configure

4)
Make the source code
$ make

5) check the make results
$ make check

6) install Protobuf
$ make install

By now you should have a completed installation of Google Protobuf. You will now be able to use it, in my case to compile the source from the RethinkDB project to create a RethinkDB instance on my Oracle Linux server.

No comments: