Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. Qt for WebAssembly
  4. Building Qt Apps to Wasm
QtWS25 Last Chance

Building Qt Apps to Wasm

Scheduled Pinned Locked Moved Unsolved Qt for WebAssembly
38 Posts 3 Posters 9.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.
  • L lorn.potter
    23 Oct 2019, 05:47

    @DragonOsman said in Building Qt Apps to Wasm:

    @lorn-potter Do I need to do a complete downgrade? I have version 1.39.0 right now. Could that be what's causing the problem with the wasm-ld error saying that my object files aren't of machine-type wasm32?

    Yes, because 1.39.0 switched to wasm object files by default, where as the older version used fastcomp to build.

    You can install a different version alongside 1.39.0:
    ./emsdk install sdk-1.38.27-64bit

    and then to switch to the newly installed version:
    ./emsdk activate --embedded sdk-1.38.27-64bit

    When you want ot use a different version just use the activate line with the correct installed version.

    D Offline
    D Offline
    DragonOsman
    wrote on 24 Oct 2019, 16:42 last edited by DragonOsman
    #22

    @lorn-potter What's the use of the patch if Qt 5 still can't handle the Wasm backend? The reason for the machine type error from wasm-ld is something else: in later versions of Emscripten, it doesn't generate bitcode for Wasm object files. But for some weird reason wasm-ld still gives an error saying that the machine type of the object files isn't wasm32. That's very strange. Please read my conversation with this LLVM developer on this Emscripten GitHub issue I've opened. It would be good if these problems are fixed so that the Wasm backend on the latest version of Emscripten works well with Qt 5.

    And right now I can't install the 1.38.27 SDK itself directly using the Emsdk; I have to install Emscripten, Clang and Binaryen separately through Emsdk and since I want to use my own Node, Python and Java anyway, I don't also get those. I had to use CMake to build and install Binaryen on my own though because what Emsdk did failed for me. When I try to install the SDK through Emsdk directly, I get a System Error Access denied when it unzips the Python zip file and gets to trying to add DLLs to the Emsdk Python installation directory.

    Edit: I deleted the old files and tried to configure and build again, but now I have this error: shared:ERROR: fastcomp is not compatible with wasm object files:main.obj. I have Emscripten 1.38.27 now with the asm.js backend, so what's going on now? Why is it generating a Wasm object file? Do I still need to add something to the .conf file so that it won't generate Wasm object files when the asm.js backend is being used?

    Also, it probably shouldn't generate Wasm object files with the Wasm backend anyway. Wasm object files aren't standard Wasm files.

    Edit: Actually, I should be able to make it work if I build Qt for WebAssembly myself. I just need to know what modules are usually built for Qt 5 for Windows. I'll build those same modules. Except if threading support isn't included in there, then I want to include that as well in addition to the rest of it. What module do I need for threading support?

    1 Reply Last reply
    0
    • D Offline
      D Offline
      DragonOsman
      wrote on 25 Oct 2019, 17:58 last edited by DragonOsman
      #23

      I want to try to building Qt for WebAssebly again since I think if I had Qt built using the latest version of Emscripten, it may not do what it's not supposed to when using that version of Emscripten. So I want to know how to have it use LLVM 10 installed through the EMSDK and have it generate LLVM bitcode targeting the wasm32 machine type (for that I probably need to know how to pass (multiple) command line arguments to the Clang compiler itself when building Qt). Also, if I want to have it use C++17 rules when building Qt, what should I do? I tried passing the -c++std c++17 argument to configure.bat but it didn't work. Internally it was still using C++11.

      I hope someone will help me with that. Thanks in advance.

      L 1 Reply Last reply 25 Oct 2019, 19:22
      0
      • D DragonOsman
        25 Oct 2019, 17:58

        I want to try to building Qt for WebAssebly again since I think if I had Qt built using the latest version of Emscripten, it may not do what it's not supposed to when using that version of Emscripten. So I want to know how to have it use LLVM 10 installed through the EMSDK and have it generate LLVM bitcode targeting the wasm32 machine type (for that I probably need to know how to pass (multiple) command line arguments to the Clang compiler itself when building Qt). Also, if I want to have it use C++17 rules when building Qt, what should I do? I tried passing the -c++std c++17 argument to configure.bat but it didn't work. Internally it was still using C++11.

        I hope someone will help me with that. Thanks in advance.

        L Offline
        L Offline
        lorn.potter
        wrote on 25 Oct 2019, 19:22 last edited by
        #24

        @DragonOsman If you install emsdk latest (1.39.0), and build Qt, you can get the new wasm object file format by passing -device-option WASM_OBJECT_FILES=1 to Qt configure.

        As far as the c++17 support, see this bug I just reported:
        https://bugreports.qt.io/browse/QTBUG-79552

        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
          DragonOsman
          wrote on 25 Oct 2019, 19:58 last edited by DragonOsman
          #25

          Okay, but how can I pass the option to emit LLVM bitcode with machine-type wasm32? Will passing -device-option WASM_OBJECT_FILES=1 to Qt configure like you said be enough? I do want to know where to pass the --emit-llvm and --target=wasm32 flags to Clang.

          Also, I heard on the Emscripten GitHub that .obj files with wasm in them aren't standard wasm files. And that Emscripten version 1.38.38 and above isn't supposed to generate it in the first place, especially with the new Wasm backend. The error I was before where wasm-ld.exe was saying that the .obj files don't have machine-type wasm32 was strange for that reason. Also because those object files all had Wasm code in them. wasm-ld.exe was also saying it about object files from the Qt library itself, though, and I don't know where to find them to check if they have Wasm code in them or not. They most likely have it as well though.

          I've posted a link to the Emscripten GitHub issue I opened about this on here before. Have you looked at that? If not, then please do.

          Also I've added this line to qmake.conf along with the recommended patch: QMAKE_CXXFLAGS_RELEASE += -Xclang --emit-llvm -Xclang --target=wasm32, but is that okay? Or did I make a mistake here? Also, if I add this patch to the Qt I build from source, and then I want to execute git pull, would it be okay to push my changes to the repository? Note: I'll keep the prebuilt binaries too and I try with both. Maybe I can still get this to work.

          Edit: One more question: do I need the Qt Web module when targeting Wasm? The one that's takes too long and the documentation says to consider not building it.

          1 Reply Last reply
          0
          • D Offline
            D Offline
            DragonOsman
            wrote on 26 Oct 2019, 09:43 last edited by DragonOsman
            #26

            This is the error I get now when using prebuilt Qt to build the Notepad project:

            wasm-ld: error: notepad.obj: machine type must be wasm32
            wasm-ld: error: notepad.js_plugin_import.obj: machine type must be wasm32
            wasm-ld: error: moc_notepad.obj: machine type must be wasm32
            wasm-ld: error: qapplication.obj: machine type must be wasm32
            wasm-ld: error: qwidget.obj: machine type must be wasm32
            wasm-ld: error: qwasmlocalfileaccess.obj: machine type must be wasm32
            shared:ERROR: 'C:/emsdk/upstream/bin\wasm-ld.exe -o c:\users\osman\appdata\local\temp\emscripten_temp\notepad.wasm --allow-undefined --lto-O0 main.obj notepad.obj -LC:\emsdk\upstream\emscripten\system\local\lib notepad.js_plugin_import.obj -LC:\emsdk\upstream\emscripten\system\lib moc_notepad.obj -LC:\Users\Osman\.emscripten_cache\wasm-obj C:/Qt/5.13.1/wasm_32/plugins/platforms/libqwasm.a C:/Qt/5.13.1/wasm_32/lib/libQt5EventDispatcherSupport.a C:/Qt/5.13.1/wasm_32/lib/libQt5FontDatabaseSupport.a C:/Qt/5.13.1/wasm_32/lib/libqtfreetype.a C:/Qt/5.13.1/wasm_32/lib/libQt5EglSupport.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqgif.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqicns.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqico.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqjpeg.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqtga.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqtiff.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqwbmp.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqwebp.a C:/Qt/5.13.1/wasm_32/lib/libQt5PrintSupport.a C:/Qt/5.13.1/wasm_32/lib/libQt5Widgets.a C:/Qt/5.13.1/wasm_32/lib/libQt5Gui.a C:/Qt/5.13.1/wasm_32/lib/libqtlibpng.a C:/Qt/5.13.1/wasm_32/lib/libqtharfbuzz.a C:/Qt/5.13.1/wasm_32/lib/libQt5Core.a C:/Qt/5.13.1/wasm_32/lib/libqtpcre2.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc.a C:\Users\Osman\.emscripten_cache\wasm-obj\libcompiler_rt.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc-wasm.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc++-noexcept.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc++abi-noexcept.a --whole-archive C:\Users\Osman\.emscripten_cache\wasm-obj\libembind-rtti.a --no-whole-archive C:\Users\Osman\.emscripten_cache\wasm-obj\libgl-webgl2.a C:\Users\Osman\.emscripten_cache\wasm-obj\libdlmalloc.a C:\Users\Osman\.emscripten_cache\wasm-obj\libpthread_stub.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc_rt_wasm.a --import-memory --import-table -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --export __wasm_call_ctors --export __data_end --export main --export malloc --export free --export setThrew --export __errno_location --export fflush --export _ZSt18uncaught_exceptionv --export __cxa_find_matching_catch --export __cxa_is_pointer_type --export __cxa_can_catch --export emscripten_GetProcAddress --export emscripten_webgl_make_context_current --export emscripten_webgl_get_current_context --export strstr --export emscripten_builtin_memalign --export memalign --export emscripten_builtin_free --export _get_environ --export realloc --export _get_tzname --export _get_daylight --export _get_timezone --export strlen -z stack-size=5242880 --initial-memory=16777216 --no-entry --global-base=1024' failed (1)
            

            If I pass -device-option WASM_OBJECT_FILES=1 to Qt configure when building Qt, will that fix this?

            I checked notepad.obj and notepad.js_plugin_import.obj with wasm-dis.exe before and found that they were Wasm object files. But now when I check again, main.obj does have Wasm code in it but this is what I get for notepad.obj:

            [parse exception: surprising value (at 0:4)]
            Fatal: error in parsing wasm binary
            

            All three of the ones from my code give the same error. How can I find those three object files from the Qt library so I can check them too?

            S 1 Reply Last reply 9 Dec 2019, 19:16
            0
            • D Offline
              D Offline
              DragonOsman
              wrote on 5 Nov 2019, 22:35 last edited by
              #27

              I finally managed to build the Notepad example app to Wasm, but I don't know how to run it. I tried opening notepad.html, but that brought me to a page with the Qt logo that says:

              Qt for WebAssembly: notepad 
              TypeError: Body has already been read
              

              So what should I do?

              Thanks in advance for any help.

              1 Reply Last reply
              0
              • L Offline
                L Offline
                lorn.potter
                wrote on 5 Nov 2019, 22:43 last edited by
                #28

                You can either put the resulting .js, .wasm, .html files on a web server, or emscripten comes with emrun which will start a server and open the html file in a browser.

                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
                  DragonOsman
                  wrote on 5 Nov 2019, 22:49 last edited by
                  #29

                  Thanks, I'll try that.

                  1 Reply Last reply
                  0
                  • D Offline
                    D Offline
                    DragonOsman
                    wrote on 6 Nov 2019, 11:02 last edited by
                    #30

                    I launched Python's web server by running python -m http.server, but I get the same exact HTML page as before when I go to notepad.html. It still has that same error on it.

                    1 Reply Last reply
                    0
                    • D Offline
                      D Offline
                      DragonOsman
                      wrote on 6 Nov 2019, 20:41 last edited by
                      #31

                      I get the exact same result with emrun. The error "TypeError: Body has already been read". How do I fix this? Someone please help. This seems like a JavaScript error so maybe I should also consult the Emscripten developers. But it's also something related to Qt and there may be something I need to know about how to run a Wasm module compiled from Qt code.

                      L 1 Reply Last reply 6 Nov 2019, 20:52
                      0
                      • D DragonOsman
                        6 Nov 2019, 20:41

                        I get the exact same result with emrun. The error "TypeError: Body has already been read". How do I fix this? Someone please help. This seems like a JavaScript error so maybe I should also consult the Emscripten developers. But it's also something related to Qt and there may be something I need to know about how to run a Wasm module compiled from Qt code.

                        L Offline
                        L Offline
                        lorn.potter
                        wrote on 6 Nov 2019, 20:52 last edited by
                        #32

                        @DragonOsman said in Building Qt Apps to Wasm:

                        The error "TypeError: Body has already been read". How do I fix this?

                        I have seen that when I configure qt for threads and have forgotten to enable shared memory in the browsers.

                        Chrome: chrome://flags "WebAssembly threads support"
                        FireFox: about:config "javascript.options.shared_memory"
                        

                        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
                        1
                        • D Offline
                          D Offline
                          DragonOsman
                          wrote on 6 Nov 2019, 20:57 last edited by
                          #33

                          Okay, thanks. I'll have to see how to do that for MS Edge. Thanks for the info on Chrome.

                          L 2 Replies Last reply 6 Nov 2019, 21:01
                          0
                          • D DragonOsman
                            6 Nov 2019, 20:57

                            Okay, thanks. I'll have to see how to do that for MS Edge. Thanks for the info on Chrome.

                            L Offline
                            L Offline
                            lorn.potter
                            wrote on 6 Nov 2019, 21:01 last edited by
                            #34

                            @DragonOsman 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
                            0
                            • D DragonOsman
                              6 Nov 2019, 20:57

                              Okay, thanks. I'll have to see how to do that for MS Edge. Thanks for the info on Chrome.

                              L Offline
                              L Offline
                              lorn.potter
                              wrote on 6 Nov 2019, 21:13 last edited by
                              #35

                              @DragonOsman said in Building Qt Apps to Wasm:

                              Okay, thanks. I'll have to see how to do that for MS Edge. Thanks for the info on Chrome.

                              I do not think Edge has re-enabled shared memory:
                              https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/SharedArrayBuffer

                              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
                                DragonOsman
                                wrote on 6 Nov 2019, 22:02 last edited by DragonOsman 11 Jun 2019, 22:03
                                #36

                                I used it in Chrome. The functionality of saving a file doesn't seem to work (may need to let WebAssembly use the filesystem) and the "Select Font" feature is giving me trouble. It opens up two dialogue boxes so I have cancel the second one. On the first one then, the font size selector goes crazy when I try to use it; it keeps going between different sets of two options in really fast succession and I can't choose one at all. Is there a special way to get the Notepad example to work as a Wasm app? These problems only appear in the Wasm app.

                                1 Reply Last reply
                                0
                                • D DragonOsman
                                  26 Oct 2019, 09:43

                                  This is the error I get now when using prebuilt Qt to build the Notepad project:

                                  wasm-ld: error: notepad.obj: machine type must be wasm32
                                  wasm-ld: error: notepad.js_plugin_import.obj: machine type must be wasm32
                                  wasm-ld: error: moc_notepad.obj: machine type must be wasm32
                                  wasm-ld: error: qapplication.obj: machine type must be wasm32
                                  wasm-ld: error: qwidget.obj: machine type must be wasm32
                                  wasm-ld: error: qwasmlocalfileaccess.obj: machine type must be wasm32
                                  shared:ERROR: 'C:/emsdk/upstream/bin\wasm-ld.exe -o c:\users\osman\appdata\local\temp\emscripten_temp\notepad.wasm --allow-undefined --lto-O0 main.obj notepad.obj -LC:\emsdk\upstream\emscripten\system\local\lib notepad.js_plugin_import.obj -LC:\emsdk\upstream\emscripten\system\lib moc_notepad.obj -LC:\Users\Osman\.emscripten_cache\wasm-obj C:/Qt/5.13.1/wasm_32/plugins/platforms/libqwasm.a C:/Qt/5.13.1/wasm_32/lib/libQt5EventDispatcherSupport.a C:/Qt/5.13.1/wasm_32/lib/libQt5FontDatabaseSupport.a C:/Qt/5.13.1/wasm_32/lib/libqtfreetype.a C:/Qt/5.13.1/wasm_32/lib/libQt5EglSupport.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqgif.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqicns.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqico.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqjpeg.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqtga.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqtiff.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqwbmp.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqwebp.a C:/Qt/5.13.1/wasm_32/lib/libQt5PrintSupport.a C:/Qt/5.13.1/wasm_32/lib/libQt5Widgets.a C:/Qt/5.13.1/wasm_32/lib/libQt5Gui.a C:/Qt/5.13.1/wasm_32/lib/libqtlibpng.a C:/Qt/5.13.1/wasm_32/lib/libqtharfbuzz.a C:/Qt/5.13.1/wasm_32/lib/libQt5Core.a C:/Qt/5.13.1/wasm_32/lib/libqtpcre2.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc.a C:\Users\Osman\.emscripten_cache\wasm-obj\libcompiler_rt.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc-wasm.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc++-noexcept.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc++abi-noexcept.a --whole-archive C:\Users\Osman\.emscripten_cache\wasm-obj\libembind-rtti.a --no-whole-archive C:\Users\Osman\.emscripten_cache\wasm-obj\libgl-webgl2.a C:\Users\Osman\.emscripten_cache\wasm-obj\libdlmalloc.a C:\Users\Osman\.emscripten_cache\wasm-obj\libpthread_stub.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc_rt_wasm.a --import-memory --import-table -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --export __wasm_call_ctors --export __data_end --export main --export malloc --export free --export setThrew --export __errno_location --export fflush --export _ZSt18uncaught_exceptionv --export __cxa_find_matching_catch --export __cxa_is_pointer_type --export __cxa_can_catch --export emscripten_GetProcAddress --export emscripten_webgl_make_context_current --export emscripten_webgl_get_current_context --export strstr --export emscripten_builtin_memalign --export memalign --export emscripten_builtin_free --export _get_environ --export realloc --export _get_tzname --export _get_daylight --export _get_timezone --export strlen -z stack-size=5242880 --initial-memory=16777216 --no-entry --global-base=1024' failed (1)
                                  

                                  If I pass -device-option WASM_OBJECT_FILES=1 to Qt configure when building Qt, will that fix this?

                                  I checked notepad.obj and notepad.js_plugin_import.obj with wasm-dis.exe before and found that they were Wasm object files. But now when I check again, main.obj does have Wasm code in it but this is what I get for notepad.obj:

                                  [parse exception: surprising value (at 0:4)]
                                  Fatal: error in parsing wasm binary
                                  

                                  All three of the ones from my code give the same error. How can I find those three object files from the Qt library so I can check them too?

                                  S Offline
                                  S Offline
                                  steno
                                  wrote on 9 Dec 2019, 19:16 last edited by
                                  #37

                                  @DragonOsman said in Building Qt Apps to Wasm:

                                  This is the error I get now when using prebuilt Qt to build the Notepad project:

                                  wasm-ld: error: notepad.obj: machine type must be wasm32
                                  wasm-ld: error: notepad.js_plugin_import.obj: machine type must be wasm32
                                  wasm-ld: error: moc_notepad.obj: machine type must be wasm32
                                  wasm-ld: error: qapplication.obj: machine type must be wasm32
                                  wasm-ld: error: qwidget.obj: machine type must be wasm32
                                  wasm-ld: error: qwasmlocalfileaccess.obj: machine type must be wasm32
                                  shared:ERROR: 'C:/emsdk/upstream/bin\wasm-ld.exe -o c:\users\osman\appdata\local\temp\emscripten_temp\notepad.wasm --allow-undefined --lto-O0 main.obj notepad.obj -LC:\emsdk\upstream\emscripten\system\local\lib notepad.js_plugin_import.obj -LC:\emsdk\upstream\emscripten\system\lib moc_notepad.obj -LC:\Users\Osman\.emscripten_cache\wasm-obj C:/Qt/5.13.1/wasm_32/plugins/platforms/libqwasm.a C:/Qt/5.13.1/wasm_32/lib/libQt5EventDispatcherSupport.a C:/Qt/5.13.1/wasm_32/lib/libQt5FontDatabaseSupport.a C:/Qt/5.13.1/wasm_32/lib/libqtfreetype.a C:/Qt/5.13.1/wasm_32/lib/libQt5EglSupport.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqgif.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqicns.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqico.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqjpeg.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqtga.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqtiff.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqwbmp.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqwebp.a C:/Qt/5.13.1/wasm_32/lib/libQt5PrintSupport.a C:/Qt/5.13.1/wasm_32/lib/libQt5Widgets.a C:/Qt/5.13.1/wasm_32/lib/libQt5Gui.a C:/Qt/5.13.1/wasm_32/lib/libqtlibpng.a C:/Qt/5.13.1/wasm_32/lib/libqtharfbuzz.a C:/Qt/5.13.1/wasm_32/lib/libQt5Core.a C:/Qt/5.13.1/wasm_32/lib/libqtpcre2.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc.a C:\Users\Osman\.emscripten_cache\wasm-obj\libcompiler_rt.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc-wasm.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc++-noexcept.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc++abi-noexcept.a --whole-archive C:\Users\Osman\.emscripten_cache\wasm-obj\libembind-rtti.a --no-whole-archive C:\Users\Osman\.emscripten_cache\wasm-obj\libgl-webgl2.a C:\Users\Osman\.emscripten_cache\wasm-obj\libdlmalloc.a C:\Users\Osman\.emscripten_cache\wasm-obj\libpthread_stub.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc_rt_wasm.a --import-memory --import-table -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --export __wasm_call_ctors --export __data_end --export main --export malloc --export free --export setThrew --export __errno_location --export fflush --export _ZSt18uncaught_exceptionv --export __cxa_find_matching_catch --export __cxa_is_pointer_type --export __cxa_can_catch --export emscripten_GetProcAddress --export emscripten_webgl_make_context_current --export emscripten_webgl_get_current_context --export strstr --export emscripten_builtin_memalign --export memalign --export emscripten_builtin_free --export _get_environ --export realloc --export _get_tzname --export _get_daylight --export _get_timezone --export strlen -z stack-size=5242880 --initial-memory=16777216 --no-entry --global-base=1024' failed (1)
                                  

                                  If I pass -device-option WASM_OBJECT_FILES=1 to Qt configure when building Qt, will that fix this?

                                  I checked notepad.obj and notepad.js_plugin_import.obj with wasm-dis.exe before and found that they were Wasm object files. But now when I check again, main.obj does have Wasm code in it but this is what I get for notepad.obj:

                                  [parse exception: surprising value (at 0:4)]
                                  Fatal: error in parsing wasm binary
                                  

                                  All three of the ones from my code give the same error. How can I find those three object files from the Qt library so I can check them too?

                                  What was your solution for machine type must be wasm32? I have been seeing this as well.

                                  L 1 Reply Last reply 10 Jan 2020, 20:35
                                  0
                                  • S steno
                                    9 Dec 2019, 19:16

                                    @DragonOsman said in Building Qt Apps to Wasm:

                                    This is the error I get now when using prebuilt Qt to build the Notepad project:

                                    wasm-ld: error: notepad.obj: machine type must be wasm32
                                    wasm-ld: error: notepad.js_plugin_import.obj: machine type must be wasm32
                                    wasm-ld: error: moc_notepad.obj: machine type must be wasm32
                                    wasm-ld: error: qapplication.obj: machine type must be wasm32
                                    wasm-ld: error: qwidget.obj: machine type must be wasm32
                                    wasm-ld: error: qwasmlocalfileaccess.obj: machine type must be wasm32
                                    shared:ERROR: 'C:/emsdk/upstream/bin\wasm-ld.exe -o c:\users\osman\appdata\local\temp\emscripten_temp\notepad.wasm --allow-undefined --lto-O0 main.obj notepad.obj -LC:\emsdk\upstream\emscripten\system\local\lib notepad.js_plugin_import.obj -LC:\emsdk\upstream\emscripten\system\lib moc_notepad.obj -LC:\Users\Osman\.emscripten_cache\wasm-obj C:/Qt/5.13.1/wasm_32/plugins/platforms/libqwasm.a C:/Qt/5.13.1/wasm_32/lib/libQt5EventDispatcherSupport.a C:/Qt/5.13.1/wasm_32/lib/libQt5FontDatabaseSupport.a C:/Qt/5.13.1/wasm_32/lib/libqtfreetype.a C:/Qt/5.13.1/wasm_32/lib/libQt5EglSupport.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqgif.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqicns.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqico.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqjpeg.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqtga.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqtiff.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqwbmp.a C:/Qt/5.13.1/wasm_32/plugins/imageformats/libqwebp.a C:/Qt/5.13.1/wasm_32/lib/libQt5PrintSupport.a C:/Qt/5.13.1/wasm_32/lib/libQt5Widgets.a C:/Qt/5.13.1/wasm_32/lib/libQt5Gui.a C:/Qt/5.13.1/wasm_32/lib/libqtlibpng.a C:/Qt/5.13.1/wasm_32/lib/libqtharfbuzz.a C:/Qt/5.13.1/wasm_32/lib/libQt5Core.a C:/Qt/5.13.1/wasm_32/lib/libqtpcre2.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc.a C:\Users\Osman\.emscripten_cache\wasm-obj\libcompiler_rt.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc-wasm.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc++-noexcept.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc++abi-noexcept.a --whole-archive C:\Users\Osman\.emscripten_cache\wasm-obj\libembind-rtti.a --no-whole-archive C:\Users\Osman\.emscripten_cache\wasm-obj\libgl-webgl2.a C:\Users\Osman\.emscripten_cache\wasm-obj\libdlmalloc.a C:\Users\Osman\.emscripten_cache\wasm-obj\libpthread_stub.a C:\Users\Osman\.emscripten_cache\wasm-obj\libc_rt_wasm.a --import-memory --import-table -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr --export __wasm_call_ctors --export __data_end --export main --export malloc --export free --export setThrew --export __errno_location --export fflush --export _ZSt18uncaught_exceptionv --export __cxa_find_matching_catch --export __cxa_is_pointer_type --export __cxa_can_catch --export emscripten_GetProcAddress --export emscripten_webgl_make_context_current --export emscripten_webgl_get_current_context --export strstr --export emscripten_builtin_memalign --export memalign --export emscripten_builtin_free --export _get_environ --export realloc --export _get_tzname --export _get_daylight --export _get_timezone --export strlen -z stack-size=5242880 --initial-memory=16777216 --no-entry --global-base=1024' failed (1)
                                    

                                    If I pass -device-option WASM_OBJECT_FILES=1 to Qt configure when building Qt, will that fix this?

                                    I checked notepad.obj and notepad.js_plugin_import.obj with wasm-dis.exe before and found that they were Wasm object files. But now when I check again, main.obj does have Wasm code in it but this is what I get for notepad.obj:

                                    [parse exception: surprising value (at 0:4)]
                                    Fatal: error in parsing wasm binary
                                    

                                    All three of the ones from my code give the same error. How can I find those three object files from the Qt library so I can check them too?

                                    What was your solution for machine type must be wasm32? I have been seeing this as well.

                                    L Offline
                                    L Offline
                                    lorn.potter
                                    wrote on 10 Jan 2020, 20:35 last edited by
                                    #38

                                    @steno said in Building Qt Apps to Wasm:

                                    What was your solution for machine type must be wasm32? I have been seeing this as well.

                                    If you use the prebuilt binaries, you need to use emscripten version 1.38.27 or 1.38.30 for threaded.

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

                                    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

                                    • Login

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