https://gcc.gnu.org/bugzilla/show_bug.cgi?id=111936
--- Comment #2 from Jonathan Wakely <redi at gcc dot gnu.org> --- (In reply to vincenzo Innocente from comment #0) > it silently compiles with > [innocent@patatrack01 ctest]$ c++ -O3 -Wall -pthread -fPIC -shared > -std=c++23 -lstdc++exp getStacktrace.cc > > but the symbols are undefined This is simply because you need to list libraries after the files that depend on them: https://c-faq.com/lib/libsearch.html When the linker sees -lstdc++exp there are no undefined references to any of the symbols it provides, so the linker ignores it. Then it sees getStacktrace.o which has undefined refs but it's too late, the archive has already been processed. The library should be compiled as PIC though, which is a separate issue.