View Full Version : How to determine build configuration?

9th January 2006, 11:48
Hi there,
I am wondering is there any way to determine if "CONFIG+=DEBUG" was specified in qmke-generated makefile?
Here's the problem:
when I compile an application in Debug mode, i want to print stack trace under some circumstances, but when compiling in release, those stacktraces are useless and only bloat the output. Is there any way to make the following code working w/o defining N_DEBUG?

void bt_sighandler(int sig, siginfo_t *info,
void *secret)

#ifdef N_DEBUG
void *trace[ trace_max_size ];
char **messages = (char **)NULL;
int i, trace_size = 0;
ucontext_t *uc = (ucontext_t *)secret;

// Do something useful with siginfo_t
if (sig == SIGSEGV)
printf("******* SEGMENTATION FAULT *******, faulty address is %p, "
"from %p\n", info->si_addr,

trace_size = backtrace(trace, trace_max_size );
// overwrite sigaction with caller's address
trace[1] = (void *) uc->uc_mcontext.gregs[REG_EIP];

messages = backtrace_symbols(trace, trace_size);
// skip first stack frame (points here)
printf("[***] Execution path:\n");
for (i=1; i<trace_size; ++i)
printf("[%3d] %s\n", trace_size - i, messages[i]);
free( messages );
printf( "[***] Backtrace not supported when compiled without N_DEBUG defined\n" );

9th January 2006, 11:59
Add such entry to your .pro file:


This will define MY_DEBUG for a debug build and MY_RELEASE for a release one. I'm sure Qt has its own define somewhere, you can look for it in a place where qDebug() is defined, as Qt only uses qDebug when in debug mode.

1st February 2006, 13:54
I have a related problem, Qt4.1.0 GPL, winxp, mingw, Dev-C++:
I built qt witih debug libs.
I made sure no QT_NO_DEBUG_OUTPUT is lurking in my makefile or pro file.
My pro file produces both realse and debug build of my prooject.
However, no output to the console seen, any idea what I can check in addition to the above?
Here is my test porgram, none of the output lines are seen on the console:

int main(int argc, char *argv[])
QApplication app(argc, argv);
MainDlg *mainDlg = new MainDlg;
std::cout<<"cout test"<<std::endl;
printf("printf test");
qDebug("qdebug test"); //none of the output lines shows on the console
return app.exec();

and I am sure the build is a "fresh" one, accourding to the file dates, and also by the fact that I see the changes on the GUI, so its not a case of "changes not updated".

1st February 2006, 13:56
Try adding "CONFIG += console" to your .pro file.

1st February 2006, 13:58
Thanks, that was it! :)