Thursday, October 8, 2015

Install Google Protocol Buffer 2.5.0 on CentOS (configure: error: C++preprocessor "/lib/cpp" fails sanity check See `config.log' for moredetails.)

Google Protocol Buffer is platform neutral, extensible tool for serializing structure data. It is inter-operable and not specific to any language.
While installing Protocol Buffer 2.5.0 on CentOS machine got configuration error, so document it as it may be useful for others.

Step 1:Download protobuf-2.5.0.tar.bz2
[code language="text"]
$ sudo wget https://github.com/google/protobuf/releases/download/v2.5.0/protobuf-2.5.0.tar.gz

--2015-09-15 11:33:14-- http://protobuf.googlecode.com/files/protobuf-2.5.0.tar.bz2
Resolving protobuf.googlecode.com... 2607:f8b0:400e:c04::52, 74.125.129.82
Connecting to protobuf.googlecode.com|2607:f8b0:400e:c04::52|:80... connected.
HTTP request sent, awaiting response... 200 OK
Length: 1866763 (1.8M) [application/x-bzip2]
Saving to: “protobuf-2.5.0.tar.bz2”

100%[======================================>] 1,866,763 2.45M/s in 0.7s
2015-09-15 11:33:15 (2.45 MB/s) - “protobuf-2.5.0.tar.bz2” saved [1866763/1866763]
[/code]

Step 2: Expand the downloaded tar file and remove the tar file
[code language="text"]
$ tar -xvf protobuf-2.5.0.tar.bz2
$ rm -rf protobuf-2.5.0.tar.bz2
[/code]

Step 3: Configure the protobuf
[code langugae="text"]
$ cd protobuf-2.5.0/
$ ./configure
[/code]
There I got error
[code langugae="text"]
configure: error: C++ preprocessor "/lib/cpp" fails sanity check See `config.log' for more details.
[/code]
Now, check if you have it the right package, links, and versions, run these commands:
[code language="text"]
$ cpp --version
cpp (GCC) 4.4.7 20120313 (Red Hat 4.4.7-16)
Copyright (C) 2010 Free Software Foundation, Inc.
This is free software; see the source for copying conditions. There is NO
warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
[/code]
If output is there then cpp lack corresponding library
[code language="text"]
$ sudo yum install glibc-headers
$ sudo yum install gcc-c++
[/code]
Now, again run configure,
[code language="text"]
$ ./configure
checking whether to enable maintainer-specific portions of Makefiles... yes
checking build system type... x86_64-unknown-linux-gnu
......................
configure: creating ./config.status
config.status: creating Makefile
config.status: creating scripts/gtest-config
config.status: creating build-aux/config.h
config.status: executing depfiles commands
config.status: executing libtool commands
[/code]

Step 4: Make
[code language="text"]
$ make
pthread -Wall -Wwrite-strings -Woverloaded-virtual -Wno-sign-compare -O2 -g -DNDEBUG -MT plugin.lo -MD -MP -MF .deps/plugin.Tpo -c -o plugin.lo `test -f 'google/protobuf/compiler/plugin.cc' || echo './'`google/protobuf/compiler/plugin.cc......
............
libtool: link: ranlib .libs/libprotobuf-lite.a
libtool: link: ( cd ".libs" && rm -f "libprotobuf-lite.la" && ln -s "../libprotobuf-lite.la" "libprotobuf-lite.la" )
make[3]: Leaving directory `/home/pooja/protobuf-2.5.0/src'
make[2]: Leaving directory `/home/pooja/protobuf-2.5.0/src'
make[1]: Leaving directory `/home/pooja/protobuf-2.5.0
[/code]

Step 5: Install
[code language="text"]
$ sudo make install
Making install in .
make[1]: Entering directory `/home/pooja/protobuf-2.5.0'
make[2]: Entering directory `/home/pooja/protobuf-2.5.0'
make[2]: Nothing to be done for `install-exec-am'.
test -z "/usr/local/lib/pkgconfig" || /bin/mkdir -p "/usr/local/lib/pkgconfig"
/usr/bin/install -c -m 644 protobuf.pc protobuf-lite.pc '/usr/local/lib/pkgconfig'
make[2]: Leaving directory `/home/pooja/protobuf-2.5.0'
atomicops_internals_x86_msvc.h google/protobuf/stubs/common.h google/protobuf/stubs/platform_macros.h google/protobuf/stubs/once.h google/protobuf/stubs/template_util.h google/protobuf/stubs/type_traits.h '/usr/local/include/google/protobuf/stubs'
.......................................
make[3]: Leaving directory `/home/pooja/protobuf-2.5.0/src'
make[2]: Leaving directory `/home/pooja/protobuf-2.5.0/src'
make[1]: Leaving directory `/home/pooja/protobuf-2.5.0/src
[/code]

Step 6: Verify protobuf installed properly
[code language="text"]
$ protoc
Missing input file.

$ protoc --version
libprotoc 2.5.0
[/code]

Hope you installed Protocol Buffer without hassel. Feel free to write to me. Thanks.

References:
Google protobuf github
Google protocol buffer tutorial

7 comments:

  1. […] 1. Java installed 2. Protocol Buffer installed 3. If maven project […]

    ReplyDelete
  2. Thank you for the steps. It worked for me.

    ReplyDelete
  3. Thanks a lot! It worked :-)

    ReplyDelete
  4. Thank you for the steps! I was stuck at the same place and now I am not! :)

    ReplyDelete
  5. thanks for the tutorial, worked great.

    ReplyDelete
  6. hi , I tried with the above steps , I am using gcc 4.4.7. I am getting some errors while installing step [make install] .
    /usr/include/x86_64-linux-gnu/bits/string_fortified.h:110: error: macro "__fortified_attr_access" requires 3 arguments, but only 1 given
    /usr/include/x86_64-linux-gnu/bits/string_fortified.h:110: error: expected initializer before ‘__fortified_attr_access’
    /usr/include/x86_64-linux-gnu/bits/string_fortified.h: In function ‘char* stpncpy(char*, const char*, size_t)’:
    /usr/include/x86_64-linux-gnu/bits/string_fortified.h:120: error: ‘__stpncpy_chk’ was not declared in this scope
    make[1]: *** [Makefile:2404: main.o] Error 1

    Can you help here ?

    ReplyDelete