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

WebAssembly - Project ERROR: Unknown module(s) in QT: quick quickcontrols2



  • Hello I have build Qt for WebAssembly manually. Here is what I have done to setup my enviorment:

    #Goes to home folder
    cd
    
    #Download Emscripten 
    git clone https://github.com/juj/emsdk.git
    cd emsdk
    ./emsdk install sdk-fastcomp-1.38.30-64bit
    ./emsdk activate --embedded sdk-fastcomp-1.38.30-64bit
    
    #Goes to home folder
    cd
    
    #Create a folder folder for Qt stuff
    mkdir Qt
    cd Qt
    
    #Download Qt and init-repository
    git clone -b 5.14.2 https://code.qt.io/qt/qt5.git
    mv qt5 5.14.2
    cd 5.14.2
    ./init-repository -f --module-subset=qtbase,qtdeclarative,qtwebsockets,qtsvg,qtquickcontrols,qtquickcontrols2,qtgraphicaleffects,qtcharts,qtdatavis3d,qtspeech,qtgraphicaleffects
    
    #Create Shadow Build directory
    mkdir ~/5.14.2-WebAssembly
    cd ~/5.14.2-WebAssembly
    
    #Configure and Build Qt for WebAssembly
    source ~/emsdk/emsdk_env.sh
    ~/Qt/5.14.2/qtbase/configure -opensource -confirm-license -xplatform wasm-emscripten -debug -feature-thread -opensource -nomake examples -nomake tests -prefix ~/Qt/5.14.2-WebAssembly-Debug
    make -j$(nproc)
    make install -j$(nproc)
    
    #Goes to home folder
    cd
    
    # Build a test project
    git clone https://github.com/msorvig/qt-webassembly-examples.git
    cd qt-webassembly-examples/quick_controls2_gallery
    ~/Qt/5.14.2-WebAssembly-Debug/bin/qmake #ERROR 
    make #Never executed because an ERROR happens on the line above
    

    Here is the outuput of qmake:

    Project MESSAGE: Setting PTHREAD_POOL_SIZE to 4
    Project MESSAGE: Setting TOTAL_MEMORY to 1GB
    Project WARNING: This Qt was built with Emscripten version 1.38.30. You have . The difference may cause issues.
    Project ERROR: Unknown module(s) in QT: quick quickcontrols2
    

    I tried:

    sudo apt install qtquickcontrols2-5-dev
    

    But nothing changed, I still get the error.


  • Moderators

    Just use the regular Qt installer to get WASM. Much easier :-)

    This Qt was built with Emscripten version 1.38.30. You have .

    Looks like your emsdk has been lost from $PATH?

    Project ERROR: Unknown module(s) in QT: quick quickcontrols2

    No idea. Perhaps you've missed something in repo init or configure.



  • Thanks @sierdzio

    I did what you suggested and worked, but the binary package only supports single-thread. As you can see here in the first paragraph of "Multithreading Support". For multi-thread (what I want), building from the source seems to be the only way.

    Regarding $PATH:
    I didn't noticed, it's strange because I am executing source ~/emsdk/emsdk_env.sh before qmake. I added the em++ path to $PATH and the Warning disappeard, but the ERROR still remains.

    I read somewhere that quick controls depend on OpenGL, here is the configure output regarding OpenGL:

    OpenGL:
      Desktop OpenGL ....................... no
      OpenGL ES 2.0 ........................ yes
      OpenGL ES 3.0 ........................ no
      OpenGL ES 3.1 ........................ no
      OpenGL ES 3.2 ........................ no
    

    Do you see any source of problem? It seems that I have one version installed.


  • Moderators

    OpenGL ES 2.0 should be enough for QtQuick controls, hmmm.

    Try to run ./configure with -v flag. It will produce a ton of output, but maybe you'll find somewhere in there a clue why it skips QtQuick.

    (also, remember to run configure from a clear location to make sure cached options are not selected)



  • @sierdzio I did what you suggested, and it seems there a lot of header files missing, giving lines like:

    main.cpp:5:10: fatal error: 'jpeglib.h' file not found
    

    I will spend some time trying to fix and then I will give you a return.

    Thanks for your help so far!



  • @sierdzio
    I found out that all libraries are installed in my system (Pop!_os 18.04), this answer in stackoverflow, let me think that it can be a linker issue.

    Below is a small piece of ./configure ... -v output regarding jpeglib.h file not found of my previous reply.
    The pattern repeats itself for many types of headers, at least it's just this type of error.

    Checking for libjpeg... 
    Trying source 0 (type pkgConfig) of library libjpeg ...
    pkg-config use disabled globally.
     => source produced no result.
    Trying source 1 (type inline) of library libjpeg ...
     => source failed condition 'config.msvc'.
    Trying source 2 (type inline) of library libjpeg ...
    + cd /home/pop_os/Qt/web-test/config.tests/libjpeg && /home/pop_os/Qt/web-test/bin/qmake "CONFIG -= qt debug_and_release app_bundle lib_bundle" "CONFIG += static warn_off console single_arch" -early "CONFIG += cross_compile" 'QMAKE_USE += libjpeg' 'QMAKE_LIBS_LIBJPEG = -ljpeg' /home/pop_os/Qt/web-test/config.tests/libjpeg
    > Project MESSAGE: Setting PTHREAD_POOL_SIZE to 4
    > Project MESSAGE: Setting TOTAL_MEMORY to 1GB
    + cd /home/pop_os/Qt/web-test/config.tests/libjpeg && MAKEFLAGS= /usr/bin/make
    > em++ -c -pipe -Os -g4 -std=gnu++11 -w -s USE_PTHREADS=1 -s PTHREAD_POOL_SIZE=4 -s TOTAL_MEMORY=1GB  -I. -I/home/pop_os/.emscripten_ports/openssl/include -I/home/pop_os/Qt/5.14.2/Src/qtbase/mkspecs/wasm-emscripten -o main.o main.cpp
    > main.cpp:5:10: fatal error: 'jpeglib.h' file not found
    > #include <jpeglib.h>
    >          ^~~~~~~~~~~
    > 1 error generated.
    > shared:ERROR: compiler frontend failed to generate LLVM bitcode, halting
    > Makefile:193: recipe for target 'main.o' failed
    > make: *** [main.o] Error 1
    => source failed verification.
    test config.qtbase_gui.libraries.libjpeg FAILED
    

  • Lifetime Qt Champion

    @Oshio said in WebAssembly - Project ERROR: Unknown module(s) in QT: quick quickcontrols2:

    main.cpp:5:10: fatal error: 'jpeglib.h' file not found

    This is not a linker issue. You do not have libjpeg (+ libjpeg-dev) installed for webassembly.



  • @jsulm
    I've executed sudo apt install libjpeg-dev and I get:

    libjpeg-dev is already the newest version (8c-2ubuntu8).
    

    This happens with every library.

    Sorry for possibly doing a dumb question, but you wrote:

    ... installed for webassembly.

    There is a specific library for webassembly, so that my attempt of installing from package manager is useless?


  • Lifetime Qt Champion

    @Oshio said in WebAssembly - Project ERROR: Unknown module(s) in QT: quick quickcontrols2:

    sudo apt install libjpeg-dev

    This is not for webassembly.
    I'm not an webassembly expert, but as far as I know it is not x86, so the host libraries cannot be used. I guess you will need to compile needed libraries for webassembly first.



  • @jsulm Uhmm now I'm starting to understand why @sierdzio told me this is not easy.
    I will do some google search on this subject, thanks for guidance.