I was trying to break down compilation to these four steps, but the last one seems problematic for me.
cpp hello.cpp > hello.i
g++ -S hello.i
as -o hello.o hello.s
ld -o hello hello.o -lstdc++
I searched the problem on here and here, but that didn't help.
Running in verbose mode gave me
attempt to open hello.o succeeded
hello.o
attempt to open /usr/i686-linux-gnu/lib32/libstdc++.so failed
attempt to open /usr/i686-linux-gnu/lib32/libstdc++.a failed
attempt to open //usr/local/lib32/libstdc++.so failed
attempt to open //usr/local/lib32/libstdc++.a failed
attempt to open //lib32/libstdc++.so failed
attempt to open //lib32/libstdc++.a failed
attempt to open //usr/lib32/libstdc++.so failed
attempt to open //usr/lib32/libstdc++.a failed
attempt to open //usr/local/lib/i386-linux-gnu/libstdc++.so failed
attempt to open //usr/local/lib/i386-linux-gnu/libstdc++.a failed
attempt to open //usr/local/lib/libstdc++.so failed
attempt to open //usr/local/lib/libstdc++.a failed
attempt to open //lib/i386-linux-gnu/libstdc++.so failed
attempt to open //lib/i386-linux-gnu/libstdc++.a failed
attempt to open //lib/libstdc++.so failed
attempt to open //lib/libstdc++.a failed
attempt to open //usr/lib/i386-linux-gnu/libstdc++.so failed
attempt to open //usr/lib/i386-linux-gnu/libstdc++.a failed
attempt to open //usr/lib/libstdc++.so failed
attempt to open //usr/lib/libstdc++.a failed
ld: cannot find -lstdc++
Any suggestions? Thanks in advance.
Instead of invoking the linker directly, try calling it indirectly through gcc or g++:
cpp hello.cpp > hello.i
g++ -S hello.i
as -o hello.o hello.s
g++ -o hello hello.o
In my case I had updated gcc to gcc-10 but left g++ at an older version (g++-9).
The fix was to install g++-10.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With