qDebug no output on CentOS

The qDebug()<<“aaaaa” is working perfectly on Windows, but when I compile the same program on CentOS, it suddenly stops working. I cannot see anything displayed on the console. Why qDebug shows nothing on CentOS? Is there any problem related to the programming environment?  I tested the printf function which can print messages without problem. So why does qDebug output nothing to the console? I added a “CONFIG+=console” line in the .pro file following the suggestion in this post,  then rebuilt the program. But the problem persisted and I saw nothing on the console. I finally solved this problem by adding an environment variable:

export QT_LOGGING_RULES="*.debug=true"

It turns out the qDebug uses a logging mechanism designed by CentOS then is restricted by the policy outside Qt. This is a bad programming habit. The program’s behavior is altered by something that is not clear outside your programming environment. This is also contradict to the autonomous philosophy in Linux. No doubt the designer of sysmctl is widely criticized by loyal developers of Linux.

Posted in

Leave a Reply