C++ preprocessor "/lib/cpp" fails sanity check

If your configure output looks similar tho this, the C++ compiler is missing:

[ ... ]
*** C++ compiler and preprocessor
checking for g++... no
checking for c++... no
checking for gpp... no
checking for aCC... no
checking for CC... no
checking for cxx... no
checking for cc++... no
checking for cl.exe... no
checking for FCC... no
checking for KCC... no
checking for RCC... no
checking for xlC_r... no
checking for xlC... no
checking whether we are using the GNU C++ compiler... no
checking whether g++ accepts -g... no
checking dependency style of g++... none
checking how to run the C++ preprocessor... /lib/cpp
configure: error: in `/home/ubuntu/.local/share/Trash/files/openmpi-1.4.1':
configure: error: C++ preprocessor "/lib/cpp" fails sanity check
See `config.log' for more details.

To install the GNU C++ compiler, use
apt-get install g++

The configure output shows that ./configure tried to find a C++ compiler by checking for a lot of known compiler names, one by one.
At the start, we see that g++ is missing - the preferred one, checked first.
But it goes on trying to find some other compiler that you may prefer to use.

I got similar type of error during installation of protobuf-2.5.0 on centos 7, for this i have to install gcc-c++ by command -

 yum install gcc-c++

My solution was to make a symlink at /lib/cpp that points to gcc.

ln -sv "$(which gcc)" /lib/cpp