Problems encountered when I use vs2022+qt6 static compilation
-
wrote on 14 Jun 2022, 04:55 last edited by
vs2022 + Qt6.3 static
Question 1:When I try to set /mt to generate release x64 in c++, I get the following prompt:
'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'But I have modified 6.3.0\Src\qtbase\mkspecs\common\msvc-desktop.conf
QMAKE_CFLAGS_RELEASE = $$QMAKE_CFLAGS_OPTIMIZE -MT
QMAKE_CFLAGS_RELEASE_WITH_DEBUGINFO += $$QMAKE_CFLAGS_OPTIMIZE -Zi -MT
QMAKE_CFLAGS_DEBUG = -Zi -MTdWhen I run configure.bat parameters:
-debug-and-release -mp -opensource -confirm-license
I think I have completed all the operations. Is there any omission?Question 2:When I use /md, the generated exe size reaches 14m. Is this normal? How can I further reduce its size?
My mother tongue is not English, so communication and reading are not very smooth. Maybe there are some solutions I need in other people's posts, but I have studied for 2 days and can't fully understand them
thanks you
-
@injertao said in Problems encountered when I use vs2022+qt6 static compilation:
Question 1:When I try to set /mt to generate release x64 in c++, I get the following prompt:
'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'
But I have modified 6.3.0\Src\qtbase\mkspecs\common\msvc-desktop.confNote that Qt itself is not built with qmake, but CMake. To build Qt itself with a static runtime (/mt), pass '-static-runtime' to configure.
Question 2:When I use /md, the generated exe size reaches 14m. Is this normal? How can I further reduce its size?
I assume you're talking about 14 MB? This obviously largely depends on which Qt modules you use ... You might furthermore reduce the size by diabling features (look into -list-features argument for configure). Anyhow, this can open a can of worms, and only few features have a noticeable impact...
-
@injertao said in Problems encountered when I use vs2022+qt6 static compilation:
Question 1:When I try to set /mt to generate release x64 in c++, I get the following prompt:
'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'
But I have modified 6.3.0\Src\qtbase\mkspecs\common\msvc-desktop.confNote that Qt itself is not built with qmake, but CMake. To build Qt itself with a static runtime (/mt), pass '-static-runtime' to configure.
Question 2:When I use /md, the generated exe size reaches 14m. Is this normal? How can I further reduce its size?
I assume you're talking about 14 MB? This obviously largely depends on which Qt modules you use ... You might furthermore reduce the size by diabling features (look into -list-features argument for configure). Anyhow, this can open a can of worms, and only few features have a noticeable impact...
wrote on 14 Jun 2022, 15:29 last edited by@kkoehne Thank you for your reply
I used -static
see:-static -debug-and-release -mp -opensource -confirm-license -optimize-size
I can compile static normally, but when I change C++ to /MT, I get an error:
'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'
-
@kkoehne Thank you for your reply
I used -static
see:-static -debug-and-release -mp -opensource -confirm-license -optimize-size
I can compile static normally, but when I change C++ to /MT, I get an error:
'RuntimeLibrary': value 'MD_DynamicRelease' doesn't match value 'MT_StaticRelease'
@injertao said in Problems encountered when I use vs2022+qt6 static compilation:
I used -static
'-static-runtime'
These are two different kind of things. You compile with a static runtime (MT) therefore you also have to compile Qt with a static runtime as @kkoehne told you.
-
@injertao said in Problems encountered when I use vs2022+qt6 static compilation:
I used -static
'-static-runtime'
These are two different kind of things. You compile with a static runtime (MT) therefore you also have to compile Qt with a static runtime as @kkoehne told you.
wrote on 15 Jun 2022, 03:54 last edited by@Christian-Ehrlicher I successfully built QT using -static -static runtime, and vs2022 successfully generated a simple exe, but this exe cannot run normally on win7 x64,
QtWidgetsApplication1. exe - System Error
The program can't start because api-ms-win-shcore-scaling-l1-1-1. dll is missing from your computer. Try reinstalling the program to fix this problem.
OK
How can I further solve this problem? I hope my exe can run without any explicit DLL.
thanks u
-
wrote on 15 Jun 2022, 05:17 last edited by injertao
@kkoehne @Christian-Ehrlicher
Please help me.SET VS_ENVIRONMENT="C:\Program Files\Microsoft Visual Studio\2022\Professional\VC\Auxiliary\Build\vcvars64.bat"
SET SRC_DIR="C:\Work\Qt\6.3.0\Src"
SET BUILD_DIR="C:\Work\Qt\6.3.0\Build"
SET INSTALL_DIR="C:\Work\Qt\6.3.0\msvc2019_64_static_size"
SET CONFIGURE_OPTIONS=-debug-and-release -mp -opensource -confirm-license -static -static-runtime -optimize-sizecall %VS_ENVIRONMENT%
mkdir %BUILD_DIR%
mkdir %INSTALL_DIR%
cd %BUILD_DIR%
call %SRC_DIR%\configure -prefix %INSTALL_DIR% %CONFIGURE_OPTIONS%
cmake --build . --parallel
cmake --install .
cmake --install . --config Debug
cd %INSTALL_DIR%
rmdir %BUILD_DIR% /Q /S
pause -
wrote on 15 Jun 2022, 05:56 last edited by
Hi, the error "No space left on device" means your C: drive is full :-(
Try removing some stuff -
Hi, the error "No space left on device" means your C: drive is full :-(
Try removing some stuffwrote on 15 Jun 2022, 05:58 last edited by@hskoglund I'm stupid, but my C drive has 100GB, isn't that enough?
-
@hskoglund I'm stupid, but my C drive has 100GB, isn't that enough?
wrote on 15 Jun 2022, 06:03 last edited by JonB@injertao
Yeah, that really should be plenty :) Re-verify you still have that much space left. It's possible that error message is "misleading". Can you manage to copy the file in question from/to the exact paths in the message? Is there some issue creating the destination path? -
@Christian-Ehrlicher I successfully built QT using -static -static runtime, and vs2022 successfully generated a simple exe, but this exe cannot run normally on win7 x64,
QtWidgetsApplication1. exe - System Error
The program can't start because api-ms-win-shcore-scaling-l1-1-1. dll is missing from your computer. Try reinstalling the program to fix this problem.
OK
How can I further solve this problem? I hope my exe can run without any explicit DLL.
thanks u
@injertao said in Problems encountered when I use vs2022+qt6 static compilation:
I successfully built QT using -static -static runtime, and vs2022 successfully generated a simple exe, but this exe cannot run normally on win7 x64
Please note Qt 6 only supports Windows 10.
-
@injertao
Yeah, that really should be plenty :) Re-verify you still have that much space left. It's possible that error message is "misleading". Can you manage to copy the file in question from/to the exact paths in the message? Is there some issue creating the destination path? -
@injertao said in Problems encountered when I use vs2022+qt6 static compilation:
SET CONFIGURE_OPTIONS=-debug-and-release -mp -opensource -confirm-license -static -static-runtime -optimize-size
[...]
@hskoglund I'm stupid, but my C drive has 100GB, isn't that enough?Well, you're asking for a static debug build + static release build of all of Qt. If you combine static with debug, executable sizes add up quite fast :)
Do you really need the debug build?
-
@injertao said in Problems encountered when I use vs2022+qt6 static compilation:
I successfully built QT using -static -static runtime, and vs2022 successfully generated a simple exe, but this exe cannot run normally on win7 x64
Please note Qt 6 only supports Windows 10.
-
@injertao said in Problems encountered when I use vs2022+qt6 static compilation:
What is the last version to support Windows 7 x64?
Qt 5.15
have 100GB on my hard drive
Check your file system. Is there enough space left?
-
@injertao said in Problems encountered when I use vs2022+qt6 static compilation:
SET CONFIGURE_OPTIONS=-debug-and-release -mp -opensource -confirm-license -static -static-runtime -optimize-size
[...]
@hskoglund I'm stupid, but my C drive has 100GB, isn't that enough?Well, you're asking for a static debug build + static release build of all of Qt. If you combine static with debug, executable sizes add up quite fast :)
Do you really need the debug build?
-
wrote on 15 Jun 2022, 12:32 last edited by
Hi, iperhaps iit is because your host OS has no space left (even thougjh your C: drive inside VMWare is ok)
This can happen when you tell VMWare to dynamically allocate space for the C: drive (i.e. not a fixed size C:) -
wrote on 15 Jun 2022, 13:28 last edited by
Note that Qt6 applications, even compiled statically, won't run on Windows 7.
If you really want to achieve this, you need to patch Qt6, see details at https://forum.qt.io/topic/133002/qt-creator-6-0-1-and-qt-6-2-2-running-on-windows-7
If you run out of disk space, you can set the NTFS compression flag of your build directory.
-
Hi, iperhaps iit is because your host OS has no space left (even thougjh your C: drive inside VMWare is ok)
This can happen when you tell VMWare to dynamically allocate space for the C: drive (i.e. not a fixed size C:)wrote on 16 Jun 2022, 07:09 last edited by@hskoglund
I confirm that the disk capacity of the host is sufficientthanks
-
Note that Qt6 applications, even compiled statically, won't run on Windows 7.
If you really want to achieve this, you need to patch Qt6, see details at https://forum.qt.io/topic/133002/qt-creator-6-0-1-and-qt-6-2-2-running-on-windows-7
If you run out of disk space, you can set the NTFS compression flag of your build directory.
wrote on 16 Jun 2022, 07:19 last edited by@cristian-adam
Thank you, I will make further Chan
1/19