We are living as nomad in Georgia !!

Install protobuf From Source

Contents

Download

protobuf Download Page

https://github.com/protocolbuffers/protobuf

Install protobuf

For CentOS / Ubuntu / MacOS

※ When installing version 3.9.0

Terminal

# wget https://github.com/protocolbuffers/protobuf/archive/v3.9.0.zip
# unzip v3.9.0.zip
# cd protobuf-3.9.0
# ./autogen.sh
# ./configure --prefix=/usr/local/protobuf/3_9_0
# make
# make install

Configure Options

--prefix

the installation path

Create Symbolic Link

Create installed libraries to under "/usr/local" by symbolic link.

Terminal

// /usr/local/bin
# ln -s /usr/local/protobuf/3_9_0/bin/protoc /usr/local/bin/

// /usr/local/include/google
# ln -s /usr/local/protobuf/3_9_0/include/google/protobuf /usr/local/include/google/

// /usr/local/lib
# ln -s /usr/local/protobuf/3_9_0/lib/libprotobuf.a /usr/local/lib/
# ln -s /usr/local/protobuf/3_9_0/lib/libprotobuf.la /usr/local/lib/
# ln -s /usr/local/protobuf/3_9_0/lib/libprotobuf-lite.a /usr/local/lib/
# ln -s /usr/local/protobuf/3_9_0/lib/libprotobuf-lite.la /usr/local/lib/
# ln -s /usr/local/protobuf/3_9_0/lib/libprotobuf-lite.so /usr/local/lib/
# ln -s /usr/local/protobuf/3_9_0/lib/libprotobuf-lite.so.20 /usr/local/lib/
# ln -s /usr/local/protobuf/3_9_0/lib/libprotobuf-lite.so.20.0.0 /usr/local/lib/
# ln -s /usr/local/protobuf/3_9_0/lib/libprotobuf.so /usr/local/lib/
# ln -s /usr/local/protobuf/3_9_0/lib/libprotobuf.so.20 /usr/local/lib/
# ln -s /usr/local/protobuf/3_9_0/lib/libprotobuf.so.20.0.0 /usr/local/lib/
# ln -s /usr/local/protobuf/3_9_0/lib/libprotoc.a /usr/local/lib/
# ln -s /usr/local/protobuf/3_9_0/lib/libprotoc.la /usr/local/lib/
# ln -s /usr/local/protobuf/3_9_0/lib/libprotoc.so /usr/local/lib/
# ln -s /usr/local/protobuf/3_9_0/lib/libprotoc.so.20 /usr/local/lib/
# ln -s /usr/local/protobuf/3_9_0/lib/libprotoc.so.20.0.0 /usr/local/lib/

// /usr/local/lib/pkgconfig
# ln -s /usr/local/protobuf/3_9_0/lib/pkgconfig/protobuf-lite.pc /usr/local/lib/pkgconfig/
# ln -s /usr/local/protobuf/3_9_0/lib/pkgconfig/protobuf.pc /usr/local/lib/pkgconfig/

Set Environment Variable

Setting LD_LIBRARY_PATH and PKG_CONFIG_PATH variables is useful when building or executing other sources.

When copying or creating a symbolic link the library installed under /usr/local, it is recommended to set it.

Terminal

$ vim ~/.bash_profile

.bash_profile

...
export LD_LIBRARY_PATH=/usr/local/lib:$LD_LIBRARY_PATH
export PKG_CONFIG_PATH=/usr/local/lib/pkgconfig:$PKG_CONFIG_PATH
...

If you want to load shared libraries in the system, create a file which is wrote "/usr/local/lib" under /etc/ld.so.conf.d.

Terminal

# echo /usr/local/lib > /etc/ld.so.conf.d/usr_local_lib.conf
# ldconfig
# ldconfig -v

Error Handling

autogen.sh: 37: ./autogen.sh: autoreconf: not found

Need to install Autoconf.

noknow

Install Autoconf From Source

autoreconf: failed to run aclocal: No such file or directory

Need to install Automake.

noknow

Install Automake From Source

configure.ac:109: error: possibly undefined macro: AC_PROG_LIBTOOL

Need to set aclocal path included .m4 files.

Terminal

# find / -name aclocal
    # autoreconf -f -i -Wall,no-obsolete -I/usr/local/libtool/2_4_6/share/aclocal

Related articles