[Interest] QWebAssembly

Sley HORTES sleyhortes13 at gmail.com
Tue May 14 12:03:12 CEST 2024



> On May 14, 2024, at 12:13 PM, Sley HORTES <sleyhortes13 at gmail.com> wrote:
> 
> Hello everyone, I have a little question I wanna post here.
> 
> I would like to run my qt app in a browser like, I have seen that I can use QwebAssembly to do so. I have already read the Documentation and installed the prerequisites (Emscripten, python3 etc).
> 
> The problem is that I am not using Qt-creator and I don’t know How to build the app so the .json and .html files got created. 
> I have seen that I am supposed to build qt from source or something but I don’t really get it neither know how to do it. 
> 
> Can someone please enlighten me about this? I am using CMake to build the app.


This is the part that is ambiguous to me. 

Building Qt from Source <https://doc.qt.io/qt-6/wasm.html#building-qt-from-source>
Building from source lets you set Qt configuration options such as thread support, OpenGL ES level, or SIMD support. Download the Qt sources from the Downloads section of your Qt account.

Configure Qt as a cross-compile build for the wasm-emscripten platform. This sets the -static, -no-feature-thread, and -no-make examples configure options. You can enable thread support with the -feature-thread, configure option. Shared library builds are not supported.

You need a host build of the same version of Qt and specify that path in the QT_HOST_PATH CMake variable or by using the -qt-host-path configure argument.

Although it should be detected, you may optionally set the CMAKE_TOOLCHAIN_FILE CMake variable to the Emscripten.cmake toolchain file that comes with Emscripten SDK. This can be done by setting the environment variable CMAKE_TOOLCHAIN_FILE or by passing CMAKE_TOOLCHAIN_FILE=/path/to/Emscripten.cmake to configure.

./configure -qt-host-path /path/to/Qt -platform wasm-emscripten -prefix $PWD/qtbase


Note: configure always uses the Ninja generator and build tool if a ninja executable is available. Ninja is cross-platform, feature-rich, performant, and recommended on all platforms. The use of other generators might work but is not officially supported.
On Windows, make sure you have MinGW in your PATH and configure with the following:

configure -qt-host-path C:\Path\to\Qt -no-warnings-are-errors -platform wasm-emscripten -prefix %CD%\qtbase


Then build the required modules:

cmake --build . -t qtbase -t qtdeclarative [-t another_module]





They are saying to use a configure script but I don’t find it anywhere in the qt installation path. Also when I am using the cmake --build in the terminal, it says that there is no CMakeLists.txt file in qt’s main directory. I just don’t know what to do. 
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.qt-project.org/pipermail/interest/attachments/20240514/5aa2c4a9/attachment.htm>


More information about the Interest mailing list