This problem can happen if different versions of g++ and gcc are installed.
g++ --version gcc --version
If these don't give the result, you probably have multiple versions of gcc installed. You can check by using:
dpkg -l | grep gcc | awk '{print $2}'
Usually, /usr/bin/gcc will be sym-linked to /etc/alternatives/gcc which is again sym-linked to say /usr/bin/gcc-4.6 or /usr/bin/gcc-4.8 (In case you have gcc-4.6, gcc-4.8 installed.)
By changing this link you can make gcc and g++ run in the same version and this may resolve your issue!
It worked, and the error goes away after I modify the softlink of /etc/alternatives/gcc from /usr/bin/gcc72 to /usr/bin/gcc48 with.
ln -fs /usr/bin/gcc48 /etc/alternatives/gcc