Looking at this question and this question I can see that for backtrace_symbols() to work, one must compile with the -rdynamic flag.
I’ve tried it into a test program and it works, but I’m writing a program that is also compiled with -static and this page says that backtrace_symbols() doesn’t work when -static is passed to the compiler/linker.
Is there any quick workaround to this or I’ll never have a human-readable backtrace function in my statically linked program?
The answer was already at hand: it was in the same page I linked in the question. At the end, I successfully used
libunwind.I was getting linking errors because I was (again) forgotting to place linker options at the end of the command line. I really don’t understand why
g++/gccdon’t issue at least a warning when ignoring command line options. The correct command line to compile is (-gisn’t needed):