Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8965631
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T16:50:59+00:00 2026-06-15T16:50:59+00:00

I need to modify existing C app and print stacktrace at certain place. How

  • 0

I need to modify existing C app and print stacktrace at certain place. How can I do this?

I can’t compile this source:

#ifndef _GNU_SOURCE
#define _GNU_SOURCE
#endif
#ifndef __USE_GNU
#define __USE_GNU
#endif

#include <execinfo.h>
#include <signal.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ucontext.h>
#include <unistd.h>


int main(int argc, char ** argv)
{
 void *             array[50];
 void *             caller_address;
 char **            messages;

 int size = backtrace(array, 50);

 /* overwrite sigaction with caller's address */
 array[1] = caller_address;

 messages = backtrace_symbols(array, size);

 /* skip first stack frame (points here) */
 for (int i = 1; i < size && messages != NULL; ++i)
 {
  fprintf(stderr, "[bt]: (%d) %s\n", i, messages[i]);
 }

 free(messages);


}

because it lacks some symbols:

$ i586-mingw32msvc-gcc -rdynamic ./trace.cpp -I/usr/include/
i586-mingw32msvc-gcc: unrecognized option '-rdynamic'
./trace.cpp:39:2: warning: no newline at end of file
/tmp/cc6hCJtU.o:trace.cpp:(.text+0x26): undefined reference to `_backtrace'
/tmp/cc6hCJtU.o:trace.cpp:(.text+0x47): undefined reference to `_backtrace_symbols'
/tmp/cc6hCJtU.o:trace.cpp:(.text+0x67): undefined reference to `_stderr'

I didn’t manage to file proper .a file.

Following answers, that can be found here on stackoverflow are practically unusable:

  • libunwind causes compile error during crosscompiling: error: ucontext.h: No such file or directory
  • http://www.codeproject.com/Articles/11132/Walking-the-callstack doesn’t compile in MinGW
  • http://www.mr-edd.co.uk/code/dbg also doesn’t compile
  • http://www.mr-edd.co.uk/code/stack_trace also doesn’t compile and has errors

Is there any working solution? Thanks alot in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-15T16:51:01+00:00Added an answer on June 15, 2026 at 4:51 pm

    Your MinGW toolchain doesn’t have support for the -rdynamic flag and cannot compile your application using backtrace() or backtrace_symbols()

    Not sure what MinGW you are using but I would recommend getting a fresh one from here: http://mingw-w64.sourceforge.net/

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to modify an existing project. In this project there are several (many)
I need to modify an existing Windows CE app which gets it data from
I need to modify an existing web app to use Castle.Windsor as IOC container.
I need to modify an existing application in order to have multilanguage support. This
I need to modify an existing script which uses SED to search and replace
I need to modify the lm (or eventually loess ) function so I can
I need to modify a php search script so that it can handle multiple
I need to modify the open-source FCKeditor (not CKeditor) to allow users to select
I need to modify an existing Perl program. I want to pipe a string
I wonder how could I modify this existing code in order to track image/banner

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.