When trying to compile the program
#include <stdio.h>
#include <stdlib.h>
#include <libunwind.h>
int main(int argc, char **argv)
{
unw_cursor_t cursor;
unw_context_t context;
// grab the machine context and initialize the cursor
if (unw_getcontext(&context) < 0)
printf("ERROR: cannot get local machine state\n");
if (unw_init_local(&cursor, &context) < 0)
printf("ERROR: cannot initialize cursor for local unwinding\n");
return 1;
}
with
gcc -lunwind main.c -o test
I do get following error:
/usr/bin/ld: /tmp/ccFDiWBz.o: in function `main':
main.c:(.text+0x23): undefined reference to `_Ux86_64_getcontext'
/usr/bin/ld: main.c:(.text+0x4c): undefined reference to `_Ux86_64_init_local'
collect2: error: ld returned 1 exit status
I have installed libunwind-dev and can see that the Symbols are in libunwind.so.8.0.1.
Do I have to link the library in a different way or what else could be the problem?
Putting
before
solved the problem.