Skip to content

Instantly share code, notes, and snippets.

@brad-anton
Last active November 26, 2018 04:26
Show Gist options
  • Star 2 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save brad-anton/a5a12eff6b5675c47da07aaffa727985 to your computer and use it in GitHub Desktop.
Save brad-anton/a5a12eff6b5675c47da07aaffa727985 to your computer and use it in GitHub Desktop.
Building Google Protocol Buffers and SDHash on Ubuntu 16.04

Install Protobuf 2.5

Install protobufs from source. If you try to use a newer version, you'll run into an error related to kEmptyString.

sudo apt-get install autoconf automake libtool curl make g++ unzip
wget https://github.com/google/protobuf/archive/v2.5.0.tar.gz
tar -zxvf v2.5.0.tar.gz
cd protobuf-2.5.0/

This is where the hacks start. protobuf depends on Google Mock, which has since been merged into Google Test. This evolution causes a few issues when getting protobuf 2.5 compiled and running make check.

First, replace the 2.5.0 autogen.sh with the current:

wget https://raw.githubusercontent.com/google/protobuf/bba446bbf2ac7b0b9923d4eb07d5acd0665a8cf0/autogen.sh

Next is to fix configure.ac to point to the new Google Mock. Modify Line 147 to read:

AC_CONFIG_SUBDIRS([gmock])

and fix the make check directive in Makefile.am my modifying Lines 20-21 to read:

	@echo "Making lib/libgmock.a lib/libgmock_main.a in gmock"
	@cd gmock && $(MAKE) $(AM_MAKEFLAGS) lib/libgmock.la lib/libgmock_main.la
	@cd gmock/gtest && $(MAKE) $(AM_MAKEFLAGS) lib/libgtest.la lib/libgtest_main.la

Now we're ready:

./autogen.sh
ln -s gmock/gtest gtest
./configure
make
make check

To support uninstall, we use checkinstall, which will build .deb and run make install.

sudo apt-get install checkinstall
sudo checkinstall -y
sudo ldconfig

Install sdhash from source

wget https://github.com/sdhash/sdhash/archive/v4.0.tar.gz
tar -zxvf v4.0.tar.gz
cd sdhash-4.0
make
sudo checkinstall -y

To build and test python bindings:

sudo apt-get install swig libboost-dev 
make swig-py
cd swig/python/
python test.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment