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?
-static
is mandatory in my program. I also tried withlibunwind
but my example programs don't link both on Ubuntu 12.04 x86 and x86_64. I'm always getting linking errors such as:undefined reference to _Ux86_init_local
undefined reference to _Ux86_get_reg
undefined reference to _Ux86_get_proc_name
undefined reference to _Ux86_step
both with binary Ubuntu libunwind and latest self-compiled libunwind downloaded from here. – Tsarina