How can I install protobuf in ubuntu 12.04?

Solution 1:

Taken from http://www.confusedcoders.com/random/how-to-install-protocol-buffer-2-5-0-on-ubuntu-13-04:

Protocol buffer is a serialization format developed by Google. It is Interface driven and is useful for applications that communicate over the wire. Below are the steps for protocol buffer installation.

  1. Download protocol buffer. Protocol buffer libs can be downloaded here. Download protocol buffer.

  2. Check if g++ compiler is installed on box. Protocol buffer needs g++ compiler to be present on your box before it can be built. This is a crisp post on how to install g++ compiler on your box. Install g++ compiler.

  3. Extract the protocol buffer archive and switch to the extracted directory.

  4. Inside the extracted directory hit the below commands to install protocol buffer. These may take a while, kindly be patient.

    ./configure
    make
    make check
    sudo make install
    protoc --version
    
  5. That's it. Protocol buffer version 2.5.0 is installed on your box.

  6. Note: Sometimes the latest version of protocol version does not load up. So we can do it manually by this command

    sudo ldconfig
    protoc --version
    

Solution 2:

It appears that 12.04 is one of the first versions containing protobuf under apt-get!

Simply run:

sudo apt-get install libprotobuf-java protobuf-compiler

and you should be all set to use protobufs with Java.

That being said, 12.04 only supports getting up to protobuf v2.4 this way. So if you need newer features, you'll need to obtain it from the github as described in the other answer.

Solution 3:

As to me, I install protpbuf 2.6.1 in ubuntu12

1. download

https://github.com/google/protobuf/releases/download/v2.6.1/protobuf-2.6.1.tar.gz

2. install

tar -zxvf protobuf-2.6.1.tar.gz  #unzip

sudo apt-get update
sudo apt-get install build-essential 

cd protobuf-2.6.1/ 

./configure

make -j10

make check -j10 

sudo make install -j10 

3. check install successfully

protoc --version # if echo 'libprotoc 2.6.1' then successfully

4. If failed

If it shows error "protoc: error while loading shared libraries: libprotoc.so.9: cannot open shared object file: No such file or directory "

sudo updatedb locate libprotoc.so.9

/usr/local/lib/libprotoc.so.9 /usr/local/lib/libprotoc.so.9.0.1

So we need add it to LD_LIBRARY_PATH

vi ~/.bashrc then add

export LD_LIBRARY_PATH=$LD_LIBRARY_PATH:/usr/local/lib

Then:

source ~/.bashrc

protoc --version

you will get libprotoc 2.6.1