Please nominate your Qt Champions for 2021!

How to disable qmake addition of -DUNICODE compiler flag

  • Hi for a project I'm working on in Qt creator I need to be able to dissable the -DUNICODE compiler flag added by qmake and replace it with a flag for MBCS.

    I do understand there may be issues with 3rd party libs by disabling unicode however I NEED to do this to use another 3rd party lib.

    How would I go about doing this? I have figured out how to add compiler flags with the QMAKE_CXX option but I can't find anything about disabling the ones that qmake adds?

    Thank you

  • You would have to change the qmake.conf in the makespecs. It's a nasty trick and will probably cause conflicts.

    However, you should always be able to specify whether you want to use the wchar_t or char version, regardless of the UNICODE macro.

  • Thanks!
    That helped alot! Exactley what I was looking for.

    unfortunatley I can't specify the string type because it's output from one 3rd party function whose type is specified by the compiler to a second 3rd party function that only accepts a particular type. I guess I could write a conversion script buy that's not what I'm looking for...

  • I had the same problem, but I think simpler solution is to add following line:
    to your .pro file.

  • Much cleaner indeed. This does mean you have to add it to every project though (or have a .pri file where you store such settings if they're common).

Log in to reply