Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. How to force MSVC to use Multibyte in QT Creator and CMake?
Qt 6.11 is out! See what's new in the release blog

How to force MSVC to use Multibyte in QT Creator and CMake?

Scheduled Pinned Locked Moved Solved General and Desktop
3 Posts 2 Posters 830 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C Offline
    C Offline
    CellAaron
    wrote on last edited by
    #1

    Hi I am currently converting an ancient MFC application into a QT one.

    This old MFC application uses libraries that use multibyte character sets but whenever I try to include them in the new QT application the application instantly crashes. I know its a problem with the multibyte characters as when I create a dummy library that uses Unicode character sets it works fine but once I switch to multibyte it crashes again.

    I have tried running these commands in my CMake file to force the MSVC compilier to use multi byte but the application still crashes.

    qt6_disable_unicode_defines(appName)
    target_compile_definitions(appName PUBLIC _MBCS)
    set(CMAKE_C_FLAGS "${CMAKE_C_FLAGS} /D _MBCS")
    set(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} /D _MBCS")

    If anyone has any help it would be greatly appreciate.

    1 Reply Last reply
    0
    • hskoglundH Offline
      hskoglundH Offline
      hskoglund
      wrote on last edited by
      #2

      Hi, I think you need to build your own complete flavor of Qt6 with those non-Unicode settings to avoid crashes, most likely an uphill battle.
      Maybe instead try building the old MFC app as a DLL with MBCS setting, then try to load it from a Qt6 app and using char* and QByteArray in the function calls across.

      C 1 Reply Last reply
      2
      • hskoglundH hskoglund

        Hi, I think you need to build your own complete flavor of Qt6 with those non-Unicode settings to avoid crashes, most likely an uphill battle.
        Maybe instead try building the old MFC app as a DLL with MBCS setting, then try to load it from a Qt6 app and using char* and QByteArray in the function calls across.

        C Offline
        C Offline
        CellAaron
        wrote on last edited by
        #3

        @hskoglund Yes you are absolutely right. I converted the dummy library to dlls and it worked.

        Sadly this is going to be a lot more work than just adding a compilier flag but at least I know what the solution is thanks.

        1 Reply Last reply
        0
        • C CellAaron has marked this topic as solved on

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved