Closed emilfors closed 10 months ago
Thanks for the bug report. Someone had a similar issue in https://github.com/slint-ui/slint/issues/1914
I thin the error happens because you are using MSVC to compile Slint (Rust target x86_64-pc-windows-msvc
, but your Qt was build with MinGW: Qt/6.4.0/mingw_64
These are not compatible.
You should either:
x86_64-pc-windows-gnu
rust target to compile Slint with Mingw-DSLINT_FEATURE_BACKEND_QT=OFF
to cmake or setting the SLINT_NO_QT=1
env variable.@tronical : could we detect that issue when we find Qt in our CMakeLists.txt ?
I thought perhaps we can check the implib properties, but those are also set for mingw, they'll just point to a .a file (that may or may not be there). Maybe the easiest would be to try_compile()
a simple Qt application? Like a proper "configure check": After find_package() located the library, compile a little test program to see if the Qt installation is "functional". That might make sense across all platforms anyway.
- Use
x86_64-pc-windows-gnu
rust target to compile Slint with Mingw- Or, Disable qt entirely by passing
-DSLINT_FEATURE_BACKEND_QT=OFF
to cmake or setting theSLINT_NO_QT=1
env variable.
Thank you. I want to try either of those two options, but I don't know how. I tried adding "--target x86_64-pc-windows-gnu" to the cmake --build build command, but that just told me that "Project file does not exist". And passing that other parameter to cmake I was told "Unknown argument -DSLINT_FEATURE_BACKEND_QT=OFF". Setting the SLINT_NO_QT=1 generated another error:
PS C:\Users\emilf\OneDrive\Documents\Slint\cpp-template> cmake --build build Microsoft (R) Build Engine version 16.11.2+f32259642 for .NET Framework Copyright (C) Microsoft Corporation. All rights reserved.
Finished dev [unoptimized + debuginfo] target(s) in 0.42s
Copying byproducts slint-compiler.exe
to C:/Users/emilf/OneDrive/Documents/Slint/cpp-template/build/_deps/slint-bui
ld Copying byproducts slint_compiler.pdb
to C:/Users/emilf/OneDrive/Documents/Slint/cpp-template/build/_deps
/slint-build
Compiling i-slint-backend-qt v1.2.2 (C:\Users\emilf\OneDrive\Documents\Slint\cpp-template\build_deps\slint-src\in
ternal\backends\qt)
Compiling i-slint-backend-selector v1.2.2 (C:\Users\emilf\OneDrive\Documents\Slint\cpp-template\build_deps\slint-
src\internal\backends\selector)
Compiling slint-interpreter v1.2.2 (C:\Users\emilf\OneDrive\Documents\Slint\cpp-template\build_deps\slint-src\int
ernal\interpreter)
Compiling slint-cpp v1.2.2 (C:\Users\emilf\OneDrive\Documents\Slint\cpp-template\build_deps\slint-src\api\cpp)
Finished dev [unoptimized + debuginfo] target(s) in 15.31s
Copying byproducts slint_cpp.dll.lib
to C:/Users/emilf/OneDrive/Documents/Slint/cpp-template/build/_deps/slint-buil
d Copying byproducts slint_cpp.dll
to C:/Users/emilf/OneDrive/Documents/Slint/cpp-template/build/_deps/slint
-build Copying byproducts slint_cpp.pdb
to C:/Users/emilf/OneDrive/Documents/Slint/cpp-template/build/_deps/
slint-build
Building Custom Rule C:/Users/emilf/OneDrive/Documents/Slint/cpp-template/build/_deps/slint-src/api/cpp/CMakeLists.tx
t
Generating appwindow.h
Building Custom Rule C:/Users/emilf/OneDrive/Documents/Slint/cpp-template/CMakeLists.txt
main.cpp
main.obj : error LNK2019: unresolved external symbol slint_native_style_metrics_init referenced in function "public:
cdecl slint::cbindgen_private::NativeStyleMetrics::NativeStyleMetrics(void *)" (??0NativeStyleMetrics@cbindgen_private@
slint@@QEAA@PEAX@Z) [C:\Users\emilf\OneDrive\Documents\Slint\cpp-template\build\my_application.vcxproj]
main.obj : error LNK2019: unresolved external symbol slint_native_style_metrics_deinit referenced in function "public:
__cdecl slint::cbindgen_private::NativeStyleMetrics::~NativeStyleMetrics(void)" (??1NativeStyleMetrics@cbindgen_private
@slint@@QEAA@XZ) [C:\Users\emilf\OneDrive\Documents\Slint\cpp-template\build\my_application.vcxproj]
main.obj : error LNK2019: unresolved external symbol imp_slint_get_NativeButtonVTable referenced in function "public:
cdecl `public: void cdecl Button_root_5::init(class AppWindow const *,class vtable::VWeak<struct slint::cbindgen_p
rivate::ComponentVTable,struct vtable::Dyn>,unsigned int64,unsigned int64)'::`2'::
To set the target to mingw:
rustup target add x86_64-pc-windows-gnu
rustup set default x86_64-pc-windows-gnu
Unknown argument -DSLINT_FEATURE_BACKEND_QT=OFF
That's strange
SLINT_NO_QT=1
The error you're seeing is because it still default to the "native" qt style. You should also set SLINT_STYLE=fluent env variable or cmake parameter (sorry, i didn't think of that)
The rustup set default command caused an error, suggesting "set default-host" instead. I tried that, but it didn't help (I still got the missing Qt6Cored.lib link error).
I then brought back the SLINT_NO_QT=1 and also added SLINT_STYLE=fluent, but with those I get the same error as before (unresolved external symbol slint_native_style_metrics_init).
I don't think I've ever struggled this hard to get a simple starter example built before.. I must be doing something seriously wrong here :D
I don't think I've ever struggled this hard to get a simple starter example built before..
I'm sorry you got so much trouble. We try to make it easy and working out of the box, but apparently this failed in your case. Slint 1.3 will be better because the default style is no longer using Qt on windows, and we added code to detect the mingw msvc incompatibility.
Unknown argument -DSLINT_FEATURE_BACKEND_QT=OFF
I think I understand the problem now. You passed this argument in the build step, but this need to be defined at configure type.
So from a fresh project, the full command should be
mkdir build
cmake -B build -DSLINT_FEATURE_BACKEND_QT=OFF
cmake --build build
I am trying to build the C++ example. I first tried with the binary Windows Slint installer, which makes the build go through but crashes the resulting exe immediately (complained about missing fromUtf8 from some Qt lib). I removed the binary and followed the instructions for building Slint from sources instead. This doesn't work, because the cmake apparently can't find 'Qt6Cored.lib'.