Results 1 to 2 of 2
Hi folks,
I am trying to build a sample stackback trace program for knowing the backtrace of a function flow.
please let me know am i missing anything here.
since ...
Enjoy an ad free experience by logging in. Not a member yet? Register.
- 12-02-2010 #1Just Joined!
- Join Date
- Dec 2010
- Posts
- 1
compilation error while building simple stack backtrace program on freebsd
Hi folks,
I am trying to build a sample stackback trace program for knowing the backtrace of a function flow.
please let me know am i missing anything here.
since i am new to FreeBSD, i am not able to find the error cause for this compilation error.
your help will me much appreciated .
here is my code and gcc commands i have used
================================================== ======
#include <execinfo.h>
#include <stdio.h>
#include <stdlib.h>
/* Obtain a backtrace and print it to stdout. */
void
print_trace (void)
{
void *array[10];
size_t size;
char **strings;
size_t i;
size = backtrace (array, 10);
strings = backtrace_symbols (array, size);
printf ("Obtained %zd stack frames.\n", size);
for (i = 0; i < size; i++)
printf ("%s\n", strings[i]);
free (strings);
}
/* A dummy function to make the backtrace more interesting. */
void
dummy_function (void)
{
print_trace ();
}
int
main (void)
{
dummy_function ();
return 0;
}
=================================================
if i use below gcc command i am getting the error as below
#gcc back_trace.c -o bt -g -lexecinfo -I /usr/local/include
/usr/bin/ld: cannot find -lexecinfo
if i use this gcc the error is different.
#gcc back_trace.c -o bt -g -I /usr/local/include
/var/tmp//cc2E2nn3.o(.text+0x10): In function `print_trace':
/var/krnaidu/my_sample/back_trace.c:15: undefined reference to `backtrace'
/var/tmp//cc2E2nn3.o(.text+0x25):/var/krnaidu/my_sample/back_trace.c:16: undefined reference to `backtrace_symbols'
please let me know which command is correct and how to solve this issue.
Thanks in advance.
--KR.
- 12-08-2010 #2Linux Guru
- Join Date
- Apr 2009
- Location
- I can be found either 40 miles west of Chicago, or in a galaxy far, far away.
- Posts
- 10,163
Ok. First, this is a LINUX kernel forum - BSD kernels are NOT Linux kernels. So, try going to a BSD support forum for this information. It will likely be very different from what you need to do in Linux.
Sometimes, real fast is almost as good as real time.
Just remember, Semper Gumbi - always be flexible!


Reply With Quote
