How to configure QT6 static?
-
I use cmake directly and successful. This is my configure:
cmake -S ../.. ^ -G Ninja ^ -DCMAKE_BUILD_TYPE=Debug ^ -DBUILD_SHARED_LIBS=OFF ^ -DFEATURE_static_runtime=ON ^ -DCMAKE_INSTALL_PREFIX="C:/Library/QT/6.8.1/VS2019/x64-debug-static" ^ -DBUILD_qtdoc=OFF ^ -DBUILD_qtwebengine=OFF ^ -DBUILD_qtwebview=OFF ^ -DBUILD_qtwayland=OFF ^ -DBUILD_WITH_PCH=OFF ^ -DQT_INTERNAL_CALLED_FROM_CONFIGURE:BOOL=TRUE ^ -DQT_QMAKE_TARGET_MKSPEC=win32-msvc ^ -DCMAKE_C_COMPILER=cl ^ -DCMAKE_CXX_COMPILER=cl ^ -DQT_BUILD_TESTS=FALSE ^ -DQT_BUILD_EXAMPLES=FALSE ^ -DFEATURE_cxx20=OFF ^ -DFEATURE_cxx2b=OFF ^ -DFEATURE_ssl=ON ^ -DINPUT_openssl=linked ^ -DFEATURE_system_zlib=ON ^ -DFEATURE_system_sqlite=ON ^ -DINPUT_libpng=system ^ -DINPUT_libjpeg=system ^ -DINPUT_freetype=system ^ -DINPUT_harfbuzz=system ^ -DINPUT_pcre=system ^ -DINPUT_doubleconversion=system ^ -DINPUT_webp=system ^ -DINPUT_tiff=system ^ -DFEATURE_icu=ON ^ -DFEATURE_gif=ON ^ -DFEATURE_ico=ON ^ -DFEATURE_vulkan=OFF ^ -DFEATURE_xcb=OFF ^ -DFEATURE_egl=OFF ^ -DFEATURE_libudev=OFF ^ -DFEATURE_slog2=OFF ^ -DFEATURE_dbus=OFF ^ -DCMAKE_CXX_STANDARD=17 ^ -DCMAKE_C_STANDARD=11 ^ -DCMAKE_EXE_LINKER_FLAGS="brotlicommon.lib brotlidec.lib brotlienc.lib bz2d.lib deflatestatic.lib libsharpyuv.lib lzma.lib rpcrt4.lib usp10.lib"
The key should be to specify libs using CMAKE_EXE_LINKER_FLAGS
-
is someone static compiling 6.8.2 in Windows 11 with VS2022 ?
I run the commandconfigure.bat -platform win32-msvc -release -static -static-runtime -prefix C:\Qt/Qt6.8.2/64 -commercial -confirm-license -plugin-manifests -nomake examples -nomake tests
I am able to compile version 6.8.1 but with version 6.8.2 I get many warnings and finally it compiles about 12000 lines (6.8.2) or source instead of about 18000 (6.8.1)
-
@rparon said in How to configure QT6 static?:
I am able to compile version 6.8.1 but with version 6.8.2 I get many warnings and finally it compiles about 12000 lines (6.8.2) or source instead of about 18000 (6.8.1)
So, does the build succeed or not? The fact that it compiles less files can be related to what modules where activated when running configure script.
-
thank you for the comment,
yes, despite the many warnings (also requesting the folder of CLang) the compling process terminates and I able to run
ninja install
however whenI try to compile my project (QML + C++) the linking process terminates showing a strange error, see below ,cannot open input file '(.obj'[ 91%] Linking CXX static library myproject.lib
[ 92%] Built target myproject
[ 92%] Built target myprojectx_autogen_timestamp_deps
[ 93%] Automatic MOC for target myprojectx
[ 93%] Built target myprojectx_autogen
[ 94%] Running AUTOMOC file extraction for target myprojectx
[ 94%] Running moc --collect-json for target myprojectx
[ 97%] Building CXX object CMakeFiles/myprojectx.dir/myprojectx_autogen/mocs_compilation.cpp.obj
[ 97%] Building CXX object CMakeFiles/myprojectx.dir/myprojectx/myprojectxx.cpp.obj
mocs_compilation.cpp
myprojectxx.cpp
[ 98%] Linking CXX shared library myprojectx.dll....
failed (exit code 1181) with the following output:
LINK : fatal error LNK1181: cannot open input file '(.obj'
jom: E:\bin\ppp\windows\64\CMakeFiles\myprojectx.dir\build.make [myprojectx.dll] Error 2
jom: E:\bin\ppp\windows\64\CMakeFiles\Makefile2 [CMakeFiles\myprojectx.dir\all] Error 2
jom: E:\bin\ppp\windows\64\Makefile [all] Error 2
01:47:28: The process "C:\CMake\bin\cmake.exe" exited with code 2.
01:47:28: Error while building/deploying project myprojectx (kit: Qt 6.8.1(64))
01:47:28: When executing step "Build"
01:47:28: Elapsed time: 00:29.which seems strange as I am unable to locate a file name with this string / substring '(.obj' inside....
do you have any clue to solve this problem ?
-
yes, I put the sources of Qt 6.8.2 in C:/Qt/6.8.2/64 and the library was compiled with VS2022 after executing
configure.bat -platform win32-msvc -release -static -static-runtime -prefix C:\Qt/Qt6.8.2/64 -commercial -confirm-license -plugin-manifests -nomake examples -nomake tests
then
cmake --build --parallel
ninja install
still I have previous version in C:/Qt/6.8.1/64 and C:/Qt/6.8.1/32 but I suppose there are no global vars which may cause conflicts...
-
sure, it was the first think to do...
- in build directory manually delete all files and folders (CMake cache,MOC files etc.etc.)
- manually delete CMakeList.txt.user to force Qt Creator to redefine all the makefiles
you may imagine I was quite surprised to see exactly the same error reported -> LINK : fatal error LNK1181: cannot open input file '(.obj'