Important: Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

Problem to run QT-Webassembly Examples



  • Hi there, i would like to try qt webassembly but i didn't get it to work.
    I made following steps:

    1. Emscripten:
    sudo apt-get install python2.7
    sudo apt-get install nodejs
    sudo apt-get install cmake
    sudo apt-get install default-jre

    git clone https://github.com/emscripten-core/emsdk.git
    cd emsdk
    git pull
    ./emsdk install latest
    ./emsdk activate latest
    source ./emsdk_env.sh

    Qt-Creator:
    Was already installed => open MaintenanceTool
    Installed QT5.13.0-rc2 (incl. sources)
    Opend Qt => Kits => Qt 5.13.0 WebAssembly (already added but without compiler)
    Added Custom Compiler to ../emscripten/emsdk/fastcomp/emscripten/emcc (and em++)
    Added Custom Path to Make for Compiler /usr/bin/make
    Now i checked the 5.13.0 examples => took dashboard => press compile

    => ERROR
    Fatal: error in validating output
    shared:ERROR: '/home/***/emscripten_5.13/emsdk/fastcomp/bin/asm2wasm dashboard.temp.asm.js --total-memory=16777216 --trap-mode=clamp -O3 --mem-init=dashboard.js.mem --mem-base=1024 --wasm-only -o dashboard.wasm --mvp-features' failed (1)

    Then I found this link:
    https://doc-snapshots.qt.io/qt5-5.13/wasm.html
    I opend a new Terminal navigated to SOURCE of 5.13.0
    Executed: ./configure -xplatform wasm-emscripten -nomake examples -prefix $PWD/qtbase
    AND: make module-qtbase module-qtdeclarative (and quickcontrols2)

    After all i tried to Build and run the test application without qtcreator
    /path/to/qt-wasm/qtbase/bin/qmake
    make

    Same error... Is there anyone who got the same issue ?



  • @davidMus

    https://wiki.qt.io/Qt_for_WebAssembly

    Can you try with emscripten sdk-1.38.27-64bit?

    emsdk install sdk-1.38.27-64bit
    emsdk activate sdk-1.38.27-64bit



  • Hello, I have a same probleme, i have install sdk-1.38.27-64bit,
    but when i try to build module i ve this error

    qwasmopenglcontext.cpp:134:27: error: no matching function for call to 'emscripten_is_webgl_context_lost'
        return !m_context || !emscripten_is_webgl_context_lost(m_context);
                              ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    /home/vnc/emsdk/emscripten/1.38.16/system/include/emscripten/html5.h:457:16: note: candidate function not viable: no known conversion from
          'const EMSCRIPTEN_WEBGL_CONTEXT_HANDLE' (aka 'const int') to 'const char *' for 1st argument
    extern EM_BOOL emscripten_is_webgl_context_lost(const char *target);
                   ^
    1 error generated.
    ERROR:root:compiler frontend failed to generate LLVM bitcode, halting
    Makefile:4853 : la recette pour la cible « .obj/qwasmopenglcontext.o » a échouée
    make[5]: *** [.obj/qwasmopenglcontext.o] Erreur 1
    make[5] : on quitte le répertoire « /home/vnc/1C/5.13.0/Src/qtbase/src/plugins/platforms/wasm »
    Makefile:124 : la recette pour la cible « sub-wasm-make_first » a échouée
    make[4]: *** [sub-wasm-make_first] Erreur 2
    make[4] : on quitte le répertoire « /home/vnc/1C/5.13.0/Src/qtbase/src/plugins/platforms »
    Makefile:51 : la recette pour la cible « sub-platforms-make_first » a échouée
    make[3]: *** [sub-platforms-make_first] Erreur 2
    make[3] : on quitte le répertoire « /home/vnc/1C/5.13.0/Src/qtbase/src/plugins »
    Makefile:670 : la recette pour la cible « sub-plugins-make_first » a échouée
    make[2]: *** [sub-plugins-make_first] Erreur 2
    make[2] : on quitte le répertoire « /home/vnc/1C/5.13.0/Src/qtbase/src »
    Makefile:50 : la recette pour la cible « sub-src-make_first » a échouée
    make[1]: *** [sub-src-make_first] Erreur 2
    make[1] : on quitte le répertoire « /home/vnc/1C/5.13.0/Src/qtbase »
    Makefile:82 : la recette pour la cible « module-qtbase » a échouée
    make: *** [module-qtbase] Erreur 2
    
    


  • @MeSakone said in Problem to run QT-Webassembly Examples:

    /home/vnc/emsdk/emscripten/1.38.16/system/include/emscripten/html5.h

    Looks like you are still using 1.38.16



  • @lorn.potter said in Problem to run QT-Webassembly Examples:

    still

    Its work thanks, but i have new problem,
    after compiling i obtain this error in a browser

    Qt for WebAssembly: gui_opengl
    Application exit (abort(-1). Build with -s ASSERTIONS=1 for more info.)
    


  • @lorn-potter
    I have installed emsdk using

    ./emsdk install sdk-fastcomp-1.38.27-64bit 
    ./emsdk activate sdk-fastcomp-1.38.27-64bit
    

    bcz installation fails(Error : No such tool/sdk) with

    ./emsdk install sdk-1.38.16-64bit
    

    and using online installer as well as offline static build
    am getting same error for simple Qt Application build
    error log

    kmb@ubuntu:~/Work/FEB2020/TestApp/build$ /home/kmb/Qt/5.14.0/wasm_32/bin/qmake ..
    
    Info: creating stash file /home/kmb/Work/FEB2020/TestApp/build/.qmake.stash
    
    kmb@ubuntu:~/Work/FEB2020/TestApp/build$ make
    
    em++ -c -pipe -O3 -std=gnu++11 -s ALLOW_MEMORY_GROWTH=1 -Wall -Wextra -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../../TestApp -I. -I../../../../Qt/5.14.0/wasm_32/include -I../../../../Qt/5.14.0/wasm_32/include/QtQuick -I../../../../Qt/5.14.0/wasm_32/include/QtGui -I../../../../Qt/5.14.0/wasm_32/include/QtQmlModels -I../../../../Qt/5.14.0/wasm_32/include/QtQml -I../../../../Qt/5.14.0/wasm_32/include/QtNetwork -I../../../../Qt/5.14.0/wasm_32/include/QtCore -I. -I/home/kmb/.emscripten_ports/openssl/include -I../../../../Qt/5.14.0/wasm_32/mkspecs/wasm-emscripten -o main.o ../main.cpp
    em++ -c -pipe -O3 -std=gnu++11 -s ALLOW_MEMORY_GROWTH=1 -Wall -Wextra -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../../TestApp -I. -I../../../../Qt/5.14.0/wasm_32/include -I../../../../Qt/5.14.0/wasm_32/include/QtQuick -I../../../../Qt/5.14.0/wasm_32/include/QtGui -I../../../../Qt/5.14.0/wasm_32/include/QtQmlModels -I../../../../Qt/5.14.0/wasm_32/include/QtQml -I../../../../Qt/5.14.0/wasm_32/include/QtNetwork -I../../../../Qt/5.14.0/wasm_32/include/QtCore -I. -I/home/kmb/.emscripten_ports/openssl/include -I../../../../Qt/5.14.0/wasm_32/mkspecs/wasm-emscripten -o testapp.js_plugin_import.o /home/kmb/Work/FEB2020/TestApp/build/testapp.js_plugin_import.cpp
    em++ -c -pipe -O3 -std=gnu++11 -s ALLOW_MEMORY_GROWTH=1 -Wall -Wextra -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../../TestApp -I. -I../../../../Qt/5.14.0/wasm_32/include -I../../../../Qt/5.14.0/wasm_32/include/QtQuick -I../../../../Qt/5.14.0/wasm_32/include/QtGui -I../../../../Qt/5.14.0/wasm_32/include/QtQmlModels -I../../../../Qt/5.14.0/wasm_32/include/QtQml -I../../../../Qt/5.14.0/wasm_32/include/QtNetwork -I../../../../Qt/5.14.0/wasm_32/include/QtCore -I. -I/home/kmb/.emscripten_ports/openssl/include -I../../../../Qt/5.14.0/wasm_32/mkspecs/wasm-emscripten -o testapp.js_qml_plugin_import.o /home/kmb/Work/FEB2020/TestApp/build/testapp.js_qml_plugin_import.cpp
    /home/kmb/Qt/5.14.0/wasm_32/bin/rcc -name qml ../qml.qrc -o qrc_qml.cpp
    em++ -c -pipe -O3 -std=gnu++11 -s ALLOW_MEMORY_GROWTH=1 -Wall -Wextra -DQT_DEPRECATED_WARNINGS -DQT_NO_DEBUG -DQT_QUICK_LIB -DQT_GUI_LIB -DQT_QMLMODELS_LIB -DQT_QML_LIB -DQT_NETWORK_LIB -DQT_CORE_LIB -I../../TestApp -I. -I../../../../Qt/5.14.0/wasm_32/include -I../../../../Qt/5.14.0/wasm_32/include/QtQuick -I../../../../Qt/5.14.0/wasm_32/include/QtGui -I../../../../Qt/5.14.0/wasm_32/include/QtQmlModels -I../../../../Qt/5.14.0/wasm_32/include/QtQml -I../../../../Qt/5.14.0/wasm_32/include/QtNetwork -I../../../../Qt/5.14.0/wasm_32/include/QtCore -I. -I/home/kmb/.emscripten_ports/openssl/include -I../../../../Qt/5.14.0/wasm_32/mkspecs/wasm-emscripten -o qrc_qml.o qrc_qml.cpp
    sed -e s/@APPNAME@/TestApp/g /home/kmb/Qt/5.14.0/wasm_32/plugins/platforms/wasm_shell.html > /home/kmb/Work/FEB2020/TestApp/build/TestApp.html
    cp -f /home/kmb/Qt/5.14.0/wasm_32/plugins/platforms/qtloader.js /home/kmb/Work/FEB2020/TestApp/build
    cp -f /home/kmb/Qt/5.14.0/wasm_32/plugins/platforms/qtlogo.svg /home/kmb/Work/FEB2020/TestApp/build
    em++ -s WASM=1 -s FULL_ES2=1 -s USE_WEBGL2=1 -s NO_EXIT_RUNTIME=0 -s ERROR_ON_UNDEFINED_SYMBOLS=1 --bind -O3 -s ALLOW_MEMORY_GROWTH=1 -o ./TestApp.js main.o testapp.js_plugin_import.o testapp.js_qml_plugin_import.o qrc_qml.o   /home/kmb/Qt/5.14.0/wasm_32/plugins/platforms/libqwasm.a /home/kmb/Qt/5.14.0/wasm_32/lib/libQt5EventDispatcherSupport.a /home/kmb/Qt/5.14.0/wasm_32/lib/libQt5FontDatabaseSupport.a /home/kmb/Qt/5.14.0/wasm_32/lib/libqtfreetype.a /home/kmb/Qt/5.14.0/wasm_32/lib/libQt5EglSupport.a /home/kmb/Qt/5.14.0/wasm_32/plugins/imageformats/libqgif.a /home/kmb/Qt/5.14.0/wasm_32/plugins/imageformats/libqicns.a /home/kmb/Qt/5.14.0/wasm_32/plugins/imageformats/libqico.a /home/kmb/Qt/5.14.0/wasm_32/plugins/imageformats/libqjpeg.a /home/kmb/Qt/5.14.0/wasm_32/plugins/imageformats/libqtga.a /home/kmb/Qt/5.14.0/wasm_32/plugins/imageformats/libqtiff.a /home/kmb/Qt/5.14.0/wasm_32/plugins/imageformats/libqwbmp.a /home/kmb/Qt/5.14.0/wasm_32/plugins/imageformats/libqwebp.a /home/kmb/Qt/5.14.0/wasm_32/qml/QtQuick.2/libqtquick2plugin.a /home/kmb/Qt/5.14.0/wasm_32/qml/QtQuick/Window.2/libwindowplugin.a /home/kmb/Qt/5.14.0/wasm_32/lib/libQt5Quick.a /home/kmb/Qt/5.14.0/wasm_32/lib/libQt5QmlModels.a /home/kmb/Qt/5.14.0/wasm_32/lib/libQt5Qml.a /home/kmb/Qt/5.14.0/wasm_32/lib/libQt5Gui.a /home/kmb/Qt/5.14.0/wasm_32/lib/libqtlibpng.a /home/kmb/Qt/5.14.0/wasm_32/lib/libqtharfbuzz.a /home/kmb/Qt/5.14.0/wasm_32/lib/libQt5Network.a /home/kmb/Qt/5.14.0/wasm_32/lib/libQt5Core.a /home/kmb/Qt/5.14.0/wasm_32/lib/libqtpcre2.a   
    shared:ERROR: '/home/kmb/Qtwasm/emsdk/fastcomp-clang/e1.38.27_64bit/binaryen/bin/asm2wasm ./TestApp.temp.asm.js --total-memory=16777216 --trap-mode=allow -O3 --mem-init=./TestApp.js.mem --mem-base=1024 --wasm-only -o ./TestApp.wasm --mvp-features' failed (-9)
    Makefile:215: recipe for target 'TestApp.js' failed
    make: *** [TestApp.js] Error 1
    

    so what is cuase here and i am using Ubuntu 18.04 VM
    kindly let me root cause