Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Windows WSL2 WSLg not rendering inside window and release only build #682

Open
AddictArts opened this issue Sep 5, 2023 · 11 comments
Open
Labels
🪲 bug Something isn't working 🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo 📖 documentation Improvements or additions to documentation

Comments

@AddictArts
Copy link

AddictArts commented Sep 5, 2023

Windows 11 x64

Passing along feedback that like other people have reported release only builds are needed on the Windows 11 side. The default or debug does not complete and create an executable. The below worked for me. The cargo only build did not work either, could not find Qt stuff. Error was QtMissing ... See also #498 and #676

cmake --build build --config Release

WSL2
WSLg
Ubuntu 22

The cmake build works and the cargo only. However, it does not render anything in the window, just a white canvas, no buttons, etc controls. The button is clickable and I see terminal output, "Hi from rust ...". Unfortunately the empty window has no workaround that I could find. I don't know if this is a Qt issue and WSLg.

Last issue Qt organization, if you download from them you are forced to use Qt6.5 and this project is not ready for that. This is unfortunate and not a good developer experience. Don't understand the poor support for prior releases. This is not anyone's here fault, just noting the latest may cause issues.

@ahayzen-kdab ahayzen-kdab added 🪲 bug Something isn't working 📖 documentation Improvements or additions to documentation 🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo labels Sep 5, 2023
@ahayzen-kdab
Copy link
Collaborator

Thanks for taking the time to report the issue.

I would be interested if someone could point to where the debug vs release build is going wrong on Windows. As a lot of this is coming from Corrosion now. Is this the issue with the "CMAKE_MSVC_RUNTIME_LIBRARY": "MultiThreadedDLL" that needs to be set ? Or is this another issue ? (and we have some fun of where to put that, eg in the root CMakeList for when people are building the repository or in each of the examples CMakeLists?).

I don't think any of us have tried this on WSLg, not many of us have even tried it on Windows.

From the Qt online installer you should be able to download any release you want via the "archive" checkbox on the right side then click "filter" (eg i can pick any version from 5.9 -> 6.6 beta).

@ahayzen-kdab
Copy link
Collaborator

Wonder if we are hitting the difference between CMAKE_BUILD_TYPE=Debug that we set in the CMakeList and --config Debug, appears that different generators might do different things there? We could try removing those lines tomorrow and see what happens...

@AddictArts
Copy link
Author

AddictArts commented Sep 5, 2023

Thanks @ahayzen-kdab

Maybe I have this wrong, I set $Env:CMAKE_MSVC_RUNTIME_LIBRARY = "MultiThreadedDLL" Did not help and same error

error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2'
LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library

For debug build

Added line 173

    )
+
+	set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")

    list(

This produced the debug build with only the LINK warning.

LINK : warning LNK4098: defaultlib 'MSVCRT' conflicts with use of other libs; use /NODEFAULTLIB:library

@AddictArts
Copy link
Author

I’m thinking the WSL2 WSLg issue is due to theme. Other Qt apps render fine. One assistant reports the theme is not set.

@ahayzen-kdab
Copy link
Collaborator

I see how we are hitting

https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-debug-cc-libraries-into-rust-fails-on-windows-msvc-targets

and

https://github.com/corrosion-rs/corrosion/blob/master/doc/src/common_issues.md#linking-rust-static-libraries-into-debug-cc-binaries-fails-on-windows-msvc-targets

These are issues that @OlivierLDff was also trying to solve. I wonder if we can set the right things in the CMakeLists for now to make things happy.

Eg do we set set_target_properties(target PROPERTIES MSVC_RUNTIME_LIBRARY "MultiThreadedDLL") and / or corrosion_set_env_vars(corrosion-crate "CFLAGS=-MDd" "CXXFLAGS=-MDd") to all our targets in CMake. So that folks can find this when following the book and it's not just hidden in the global CMakeList / preset.

I also wonder if we can get away with one of them and if they work for both Debug and Release builds or whether there is more fine tuning to do there...

@ahayzen-kdab
Copy link
Collaborator

Or maybe we just set in all our CMake files so it happens everywhere and easy for folks to see in the examples 🤷

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
  set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
endif()

ahayzen-kdab added a commit to ahayzen-kdab/cxx-qt that referenced this issue Sep 6, 2023
ahayzen-kdab added a commit to ahayzen-kdab/cxx-qt that referenced this issue Sep 6, 2023
As Rust always uses the non-debug Windows runtime for MSVC targets.

Related to KDAB#682
Related to KDAB#676
@ahayzen-kdab
Copy link
Collaborator

Would be interesting if #683 makes things better or worse :-)

@OlivierLDff
Copy link
Contributor

Or maybe we just set in all our CMake files so it happens everywhere and easy for folks to see in the examples 🤷

if (CMAKE_CXX_COMPILER_ID STREQUAL "MSVC")
  set(CMAKE_MSVC_RUNTIME_LIBRARY "MultiThreadedDLL")
endif()

This is the "best" way to handle it that will break less stuff that #683

ahayzen-kdab added a commit to ahayzen-kdab/cxx-qt that referenced this issue Sep 6, 2023
As Rust always uses the non-debug Windows runtime for MSVC targets.

Related to KDAB#682
Related to KDAB#676
ahayzen-kdab added a commit to ahayzen-kdab/cxx-qt that referenced this issue Sep 6, 2023
As Rust always uses the non-debug Windows runtime for MSVC targets.

Related to KDAB#682
Related to KDAB#676
ahayzen-kdab added a commit to ahayzen-kdab/cxx-qt that referenced this issue Sep 6, 2023
As Rust always uses the non-debug Windows runtime for MSVC targets.

Related to KDAB#682
Related to KDAB#676
@ahayzen-kdab
Copy link
Collaborator

#683 should solve the _ITERATOR_DEBUG_LEVEL issue :-)

@ahayzen-kdab
Copy link
Collaborator

After ensuring that the folder that contains qmake.exe is in PATH and using #683.

I can run (using msvc2019 + Qt online installer 5.15.2) CMake builds and targets from QtCreator and I can run cargo run -p qml-minimal-no-cmake and it also shows a window correctly.

So the remaining issue on this task is whether something specific to WSL2 / WSLg is broken, as you suggested maybe it is a theming problem ? Can you run without any custom themes and see if that helps ?

ahayzen-kdab added a commit that referenced this issue Sep 8, 2023
ahayzen-kdab added a commit that referenced this issue Sep 8, 2023
As Rust always uses the non-debug Windows runtime for MSVC targets.

Related to #682
Related to #676
@klochowicz
Copy link

FWIW I have managed to run the latest main branch example qml-features just fine after using Qt online installer (6.6.0) with gcc_64 , both in debug and release builds on my Ubuntu WSL2 environment.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🪲 bug Something isn't working 🔨 build system Issues related to integrating CXX-Qt into CMake/Cargo 📖 documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants