Hi,

I would like to redirect all the debug message to a file. In order to do so, I call 'qInstallMsgHandler' in the main.cpp to install a message handler that would do the job but the compiler complains and gives me a C3861: 'qInstallMsgHandler': identifier not found error message.

qInstallMsgHandler is declared in the QtGlobal header and QtGlobal is included in my main.ccp, so it should find it. Could someone help me to understand that error, please? Thanks.
Qt Code:
  1. #include <QApplication>
  2. #include <QtGui>
  3. #include <QtGlobal>
  4. #include "mainwindow.h"
  5.  
  6. #define DEBUG_TEST
  7.  
  8. #ifdef DEBUG_TEST
  9. void crashMessageOutput(QtMsgType type, const char *msg)
  10. {
  11. switch (type)
  12. {
  13. case QtDebugMsg:
  14. fprintf(stderr, "Debug: %s\n", msg);
  15. break;
  16. case QtWarningMsg:
  17. fprintf(stderr, "Warning: %s\n", msg);
  18. break;
  19. case QtCriticalMsg:
  20. fprintf(stderr, "Critical: %s\n", msg);
  21. break;
  22. case QtFatalMsg:
  23. fprintf(stderr, "Fatal: %s\n", msg);
  24. abort();
  25. }
  26. }
  27. #endif
  28.  
  29. int main(int argc, char *argv[])
  30. {
  31. #ifdef DEBUG_TEST
  32. qInstallMsgHandler(crashMessageOutput);
  33. #endif
  34. QApplication app(argc, argv);
  35. MainWindow theMainWindow;
  36. theMainWindow.show();
  37. return app.exec();
  38. }
To copy to clipboard, switch view to plain text mode