How to force MSVC to use Multibyte in QT Creator and CMake?
-
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.
-
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. -
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.@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.
-
C CellAaron has marked this topic as solved on