I am facing this weird issue with gcc 11.3.0, a -O3 build works, whereas when I build with -O0 -g (debug build), I get linker error:
/usr/bin/ld: path/to/mylib.a(my_file.cpp.2.o): undefined reference to symbol '_ZNSt6localeD1Ev@@GLIBCXX_3.4'
/usr/bin/ld: /lib/x86_64-linux-gnu/libstdc++.so.6: error adding symbols: DSO missing from command line
From other answers on similar topic, I tried to add -lstdc++ but that gave a lot
more errors! Is this a C vs CPP link issue ? If so, why do I see it only with -O0 and not -O3 ?
How to fix this ? (how to check which library the symbol is coming from?)
-- Thanks