Find the answer to your Linux question:
Results 1 to 2 of 2
Enjoy an ad free experience by logging in. Not a member yet? Register.
  1. #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. */
    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. */
    dummy_function (void)
    print_trace ();

    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.


  2. #2
    Linux Guru Rubberman's Avatar
    Join Date
    Apr 2009
    I can be found either 40 miles west of Chicago, in Chicago, or in a galaxy far, far away.
    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!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts