g ++ - 4.1 is available for Ubuntu; just run apt-get install g++-4.1, then run g++-4.1instead g++. However, simply using an older compiler may not fix all the problems in your library.
As Joachim Sauer said, it's best to do your development on Ubuntu, and then do the final compilation on CentOS.
Although you use C ++, static binding should still be an option. (However, you are much better at compiling CentOS and using dynamic linking.)
: - CentOS, Ubuntu CentOS, , CentOS Fedora, chroot , . .