Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QT-Webassembly - Compile Examples
Forum Update on Monday, May 27th 2025

QT-Webassembly - Compile Examples

Scheduled Pinned Locked Moved Solved General and Desktop
6 Posts 3 Posters 1.0k Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • D Offline
    D Offline
    David_001
    wrote on 1 Aug 2019, 13:57 last edited by David_001 8 Jan 2019, 14:03
    #1

    Hi everybody,

    i would like to compile some of the qt examples with emcc compiler, but i have some trouble with it.
    I already searched for this error some hours but didn't get a good solution.

    So here is what i have done:

    1. Downloaded qt web installer (linux) from qt.io
    2. Installed qt 5.13 (complete) => with sources and Webassembly
    3. => Since 5.13 i think there is no need to compile Webassembly on his own like on 5.12 anymore.
    4. Than i installed emcc like the instruction on emscription.org said.

    git clone https://github.com/emscripten-core/emsdk.git
    cd emsdk
    git pull
    ./emsdk install latest
    ./emsdk activate latest
    source ./emsdk_env.sh
    sudo apt-get install python2.7
    sudo apt-get install cmake
    sudo apt-get install default-jre
    

    After i have done that i verified the emcc installation. Everything is fine.

    5. Started QtCreator => There is already an QtWebassembly Kit but without an Compiler
    6. Added emcc and em++ compiler to QtCreator (custom-compiler)

    Name: emcc
    Compiler-Path:  ~/work/privat/project/emc/emsdk/fastcomp/emscripten/emcc
    Path to Make: /usr/bin/make
    ABI: x86,linux,generic, elf,64bit
    QT-mkspecs: empty
    
    Name: em++
    Compiler-Path:  ~/work/privat/project/emc/emsdk/fastcomp/emscripten/em++
    Path to Make: /usr/bin/make
    ABI: x86,linux,generic, elf,64bit
    QT-mkspecs: empty
    
    Everything else on Default.
    

    7. Added Compiler to QtWebassembly-Kit
    8. Opened any example from Qt and also made a simple Window with an anchors.fill red Rectangle
    9. Compiling staring like always BUTTTTT than there where some issues.

    warning: unexpected return type i32 in call to 'lseek', should be i64
    warning: unexpected argument type i32 at index 5 in call to '__mmap', should be i64
    warning: unexpected argument type i32 at index 5 in call to '__mmap', should be i64
    warning: unexpected argument type i32 at index 5 in call to '__mmap', should be i64
    warning: unexpected argument type i32 at index 5 in call to '__mmap', should be i64
    warning: unexpected argument type i32 at index 5 in call to '__mmap', should be i64
    warning: unexpected argument type i32 at index 1 in call to 'lseek', should be i64
    warning: unexpected return type i32 in call to 'lseek', should be i64
    warning: unexpected argument type i32 at index 5 in call to '__mmap', should be i64
    emcc: warning: cannot represent a NaN literal '0x1b1af280' with custom bit pattern in NaN-canonicalizing JS engines (e.g. Firefox and Safari) without erasing bits!
      in   ret double 0x7FF4000000000000 in _ZL7qt_snanv() 
    emcc: warning: cannot represent a NaN literal '0x1b1af280' with custom bit pattern in NaN-canonicalizing JS engines (e.g. Firefox and Safari) without erasing bits!
      in   ret double 0x7FF4000000000000 in _ZL7qt_snanv.24722() 
    warning: unexpected return type i32 in call to '__ftello', should be i64
    warning: unexpected argument type i32 at index 1 in call to 'lseek', should be i64
    warning: unexpected return type i32 in call to 'lseek', should be i64
    

    After a while QtCreator starts printing a lot lot lot lot output in assmbly (takes lot of time)

    alt text

    Ending up with this error:

    fatal: error in validating output shared:error:
    --total-memory=16777216 --trap-mode=clamp -Os --mem-init=./untitled.js.mem --mem-base=1024 --wasm-only -g -o ./untitled.wast -S --mvp-features' failed (1)
    

    As i said i already searched for it at google and tried some option i found:

    QMAKE_CXXFLAGS += -s WASM=0
    QMAKE_CXXFLAGS += -s TOTAL_MEMORY=52428800
    

    Still the same :( Does anyone knows where i made a mistake ? What am i doing wrong?

    L 1 Reply Last reply 10 Aug 2019, 04:42
    0
    • D David_001
      1 Aug 2019, 13:57

      Hi everybody,

      i would like to compile some of the qt examples with emcc compiler, but i have some trouble with it.
      I already searched for this error some hours but didn't get a good solution.

      So here is what i have done:

      1. Downloaded qt web installer (linux) from qt.io
      2. Installed qt 5.13 (complete) => with sources and Webassembly
      3. => Since 5.13 i think there is no need to compile Webassembly on his own like on 5.12 anymore.
      4. Than i installed emcc like the instruction on emscription.org said.

      git clone https://github.com/emscripten-core/emsdk.git
      cd emsdk
      git pull
      ./emsdk install latest
      ./emsdk activate latest
      source ./emsdk_env.sh
      sudo apt-get install python2.7
      sudo apt-get install cmake
      sudo apt-get install default-jre
      

      After i have done that i verified the emcc installation. Everything is fine.

      5. Started QtCreator => There is already an QtWebassembly Kit but without an Compiler
      6. Added emcc and em++ compiler to QtCreator (custom-compiler)

      Name: emcc
      Compiler-Path:  ~/work/privat/project/emc/emsdk/fastcomp/emscripten/emcc
      Path to Make: /usr/bin/make
      ABI: x86,linux,generic, elf,64bit
      QT-mkspecs: empty
      
      Name: em++
      Compiler-Path:  ~/work/privat/project/emc/emsdk/fastcomp/emscripten/em++
      Path to Make: /usr/bin/make
      ABI: x86,linux,generic, elf,64bit
      QT-mkspecs: empty
      
      Everything else on Default.
      

      7. Added Compiler to QtWebassembly-Kit
      8. Opened any example from Qt and also made a simple Window with an anchors.fill red Rectangle
      9. Compiling staring like always BUTTTTT than there where some issues.

      warning: unexpected return type i32 in call to 'lseek', should be i64
      warning: unexpected argument type i32 at index 5 in call to '__mmap', should be i64
      warning: unexpected argument type i32 at index 5 in call to '__mmap', should be i64
      warning: unexpected argument type i32 at index 5 in call to '__mmap', should be i64
      warning: unexpected argument type i32 at index 5 in call to '__mmap', should be i64
      warning: unexpected argument type i32 at index 5 in call to '__mmap', should be i64
      warning: unexpected argument type i32 at index 1 in call to 'lseek', should be i64
      warning: unexpected return type i32 in call to 'lseek', should be i64
      warning: unexpected argument type i32 at index 5 in call to '__mmap', should be i64
      emcc: warning: cannot represent a NaN literal '0x1b1af280' with custom bit pattern in NaN-canonicalizing JS engines (e.g. Firefox and Safari) without erasing bits!
        in   ret double 0x7FF4000000000000 in _ZL7qt_snanv() 
      emcc: warning: cannot represent a NaN literal '0x1b1af280' with custom bit pattern in NaN-canonicalizing JS engines (e.g. Firefox and Safari) without erasing bits!
        in   ret double 0x7FF4000000000000 in _ZL7qt_snanv.24722() 
      warning: unexpected return type i32 in call to '__ftello', should be i64
      warning: unexpected argument type i32 at index 1 in call to 'lseek', should be i64
      warning: unexpected return type i32 in call to 'lseek', should be i64
      

      After a while QtCreator starts printing a lot lot lot lot output in assmbly (takes lot of time)

      alt text

      Ending up with this error:

      fatal: error in validating output shared:error:
      --total-memory=16777216 --trap-mode=clamp -Os --mem-init=./untitled.js.mem --mem-base=1024 --wasm-only -g -o ./untitled.wast -S --mvp-features' failed (1)
      

      As i said i already searched for it at google and tried some option i found:

      QMAKE_CXXFLAGS += -s WASM=0
      QMAKE_CXXFLAGS += -s TOTAL_MEMORY=52428800
      

      Still the same :( Does anyone knows where i made a mistake ? What am i doing wrong?

      L Offline
      L Offline
      lorn.potter
      wrote on 10 Aug 2019, 04:42 last edited by
      #2

      @david_001 What version of emscripten do you have?
      Qt 5.13 webassembly requires 1.38.27
      https://wiki.qt.io/Qt_for_WebAssembly

      Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
      Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

      1 Reply Last reply
      3
      • D Offline
        D Offline
        David_001
        wrote on 10 Aug 2019, 17:07 last edited by David_001 8 Oct 2019, 17:08
        #3

        Lastest => 1.38.39 shouldn't it work with a newer version as well?

        L 1 Reply Last reply 20 Aug 2019, 20:16
        0
        • D David_001
          10 Aug 2019, 17:07

          Lastest => 1.38.39 shouldn't it work with a newer version as well?

          L Offline
          L Offline
          lorn.potter
          wrote on 20 Aug 2019, 20:16 last edited by
          #4

          @david_001
          emscripten can and do make radical and non compatible changes. So we decided that we would tie a certain Qt version to a certain emscripten version.
          We have not made any changes to enforce this, or at least to point out to the developer that a certain version is required.

          Freelance Software Engineer, Platform Maintainer QtWebAssembly, Maintainer QtSensors
          Author, Hands-On Mobile and Embedded Development with Qt 5 http://bit.ly/HandsOnMobileEmbedded

          1 Reply Last reply
          0
          • D Offline
            D Offline
            David_001
            wrote on 1 Sept 2019, 17:57 last edited by David_001 9 Apr 2019, 11:56
            #5

            I used the Version you recommended, with the Version 1.38.27 the compilation will successfully.

            Here a Tutorial to setup:

            1. Downloaded qt web installer (linux) from qt.io
            2. Installed qt 5.13 (complete) => with sources and Webassembly
            3. => Since 5.13 i think there is no need to compile Webassembly on his own like on 5.12 anymore.
            4. Than i installed emcc like the instruction on emscription.org said.

            git clone https://github.com/emscripten-core/emsdk.git
            cd emsdk
            git pull
            ./emsdk install sdk-1.38.27-64bit
            ./emsdk activate sdk-1.38.27-64bit
            source ./emsdk_env.sh
            sudo apt-get install python2.7
            sudo apt-get install cmake
            sudo apt-get install default-jre
            

            After i have done that i verified the emcc installation. Everything is fine.

            5. Started QtCreator => There is already an QtWebassembly Kit but without an Compiler
            6. Added emcc and em++ compiler to QtCreator (custom-compiler)

            Name: emcc
            Compiler-Path:  ~/work/privat/project/emsdk/emscripten/1.38.27/emcc
            Path to Make: /usr/bin/make
            ABI: x86,linux,generic, elf,64bit
            QT-mkspecs: empty
            
            Name: em++
            Compiler-Path:  ~/work/privat/project/emsdk/emscripten/1.38.27/em++
            Path to Make: /usr/bin/make
            ABI: x86,linux,generic, elf,64bit
            QT-mkspecs: empty
            
            Everything else on Default.
            

            7. Added Compiler to QtWebassembly-Kit
            8. DONE

            1 Reply Last reply
            0
            • N Offline
              N Offline
              NativeCasinos
              Banned
              wrote on 2 Sept 2019, 11:00 last edited by
              #6
              This post is deleted!
              1 Reply Last reply
              -2

              • Login

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • Users
              • Groups
              • Search
              • Get Qt Extensions
              • Unsolved