I'm trying to dip my toes into Qt WebAssembly in Windows 10, so I performed the necessary setup as per the Qt for WebAssembly instructions. With that I now have the following installed:
- Qt: 6.5.2
- Qt Creator: 11.0
- emsdk: 3.1.25
In Qt Creator Preferences > Devices > WebAssembly I see the following:
Adding directories to PATH:
C:\dev\emsdk-3.1.44\node\16.20.0_64bit\bin
C:\dev\emsdk-3.1.44\upstream\emscripten
C:\dev\emsdk-3.1.44
C:\dev\emsdk-3.1.44\python\3.9.2-nuget_64bit
Setting environment variables:
EMSDK=C:/dev/emsdk-3.1.44
EMSDK_NODE=C:\dev\emsdk-3.1.44\node\16.20.0_64bit\bin\node.exe
EMSDK_PYTHON=C:\dev\emsdk-3.1.44\python\3.9.2-nuget_64bit\python.exe
JAVA_HOME=C:\dev\emsdk-3.1.44\java\8.152_64bit
which looks like it should be OK from what I can see (note: I downloaded the latest emsdk release from GitHub and used it to install 3.1.25), and it is showing the activated version as 3.1.25.
Going into Preferences > Kits > Kits I can see the C and C++ compiler for WebAssembly Qt 6.5.2 (multi-threaded)
is Emscripten Compiler 3.1.25 for C/C++
which also looks to be correct based on everything I've managed to surmise.
At this point I create a new Qt Widgets Application
project called Test and tell it to use the Desktop Qt 6.5.2 MinGW 64-bit
and WebAssembly Qt 6.5.2 (multi-threaded)
kits. Without making changes to what is generated by Qt Creator I can launch the project as a Desktop application and see the empty window appear on screen. However when I switch to WebAssembly I am greeted by an error
<path>\Test\Test.pro:-1: error: Error while parsing file <path>\Test\Test.pro. Giving up.
The project only lists the Test.pro file and nothing else (when in desktop I can see all h, cpp, and ui files). If I try to compile the project all I get is the following error:
Error while building/deploying project Test (kit: WebAssembly Qt 6.5.2 (multi-threaded))
When executing step "Make"
I haven't touched any of the generated files (h, cpp, ui, pro), and am very much as a loss as to what's going on. My Test.pro is as follows:
QT += core gui
greaterThan(QT_MAJOR_VERSION, 4): QT += widgets
CONFIG += c++17
# You can make your code fail to compile if it uses deprecated APIs.
# In order to do so, uncomment the following line.
#DEFINES += QT_DISABLE_DEPRECATED_BEFORE=0x060000 # disables all the APIs deprecated before Qt 6.0.0
SOURCES += \
main.cpp \
mainwindow.cpp
HEADERS += \
mainwindow.h
FORMS += \
mainwindow.ui
# Default rules for deployment.
qnx: target.path = /tmp/$${TARGET}/bin
else: unix:!android: target.path = /opt/$${TARGET}/bin
!isEmpty(target.path): INSTALLS += target
Update
Finally got around to looking into this some more, and it appears to be tied to WebAssembly Qt 6.5.2 (multi-threaded)
. If I use WebAssembly Qt 6.5.2 (single-threaded)
then everything looks to work as expected...