All of what you did is just right. But you miss to do one important thing.
sudo ppa-purge ppa:ubuntu-toolchain-r/test
sudo apt-add-repository --remove ppa:ubuntu-toolchain-r/test
And manually removed the PPA file from /etc/apt/sources.list.d as well
as the keyring.
Now before doing
sudo apt-get upgrade
you should make
sudo apt-get update
then make
sudo apt-get upgrade
Your problem is you are still working on the software list that containing that repository, so you have to do apt-get update
to update this list without the ubuntu-toolchain-r/test
repository.
The problem you have is related to C++11 standard requiring a different implementation of C++ string (and list) type(s). For compatibility, g++5.2 and above compiles the new C++11 compliant type by default, (whether or not you specify -std=c++11), but you can set the macro
-D_GLIBCXX_USE_CXX11_ABI=0
to revert to the old C++ string type. New libstdc++ implementation contain both ABIs. So if you have binaries you have to link against with the old non-compliant ABI, you must set the macro above on your g++ compiles. This should produce binaries compatible with the old ABI.
Unfortunately if you are using libraries from the OS other than the C++ Standard Libraries, then unless these libraries are multi-arch in the sense of providing all functions which differ by ABI in both ABI's, then you're screwed because they'll probably only have the new ABI.
Having said that I have a problem on an old Ubuntu downloading an untrusted modern g++ which simply refuses to produce the new ABI. So it seems that backport from ppa:ubuntu-toolchain-r/test
is in fact badly broken because it refuses to produce binaries according to the new ABI.
Anyhow the bottom line is when you link together everything must either be the old ABI or the new ABI. The following will tell which you are using:
g++ --version
echo '#include <string>' > test.cpp
echo 'void f(std::string s) {}' >> test.cpp
cat test.cpp
g++ -std=gnu++11 -c -o test.o test.cpp
nm test.o | c++filt
If that has
std::basic_string<char, ....
in it, its the old ABI. If it has
std::__cxx11::basic_string<char, ...
in it, its the new ABI.
Best Answer
Available is:
sudo apt install g++-4.8
And the no PIE
gcc54-c++_5.4.0-ubuntu16_amd64.deb
https://drive.google.com/file/d/1ptHLaZXImpeMzq4xuuGGn5VjrvxNSop3/view?usp=sharing , Ref. https://stackoverflow.com/questions/50213089/linking-error-with-gcc-g-7-3-0-on-ubuntu-18-04/50232797#50232797 → My answer.Or add
xenial
to/etc/apt/sources.list
temporarily :sudo gedit /etc/apt/sources.list
... and do
sudo apt update && sudo apt install g++-4.9