How to Run a Qt WebAssembly App on an Nginx Server?
-
Hey there,
First things first: Qt Creator 10.0.1, WebAssembly Qt 6.4.3, Emscripten 3.1.14 and I'm a beginner.
I have made an app with Qt (QML, C++, CMake). I was able to build the app with Qt Creator and run it locally in my browser.
Now, I have borrowed some server space from a friend (Linux server with nginx). I have set up the server block / virtual host, but I just can't seem to figure out how I would actually run the app on the server.
Locally, I can just use Qt Creator or use the command prompt with:
emrun --port=... --browser=... app.htmlto run it.
For the server I tried to create a Dockerfile:
FROM scratch COPY /app.wasm /app.wasm ENTRYPOINT ["app.wasm"]and then build the docker image with:
docker buildx build --platform wasi/wasm32 -t app .from the already build "app.wasm" file.
The building finishes, but throws the errorexporting to image, yet somehow the image is still being created.
Afterwards I'm trying to run the image using:docker run --rm --name=docker-app --runtime=io.containered.wasmedge.v1 --platform=wasi/wasm32 app:latestbut I'm always getting the following errors:
[2023-06-22 16:09:51.485] [error] instantiation failed: unknown import, Code: 0x62 [2023-06-22 16:09:51.485] [error] When linking module: "env" , function name: "__cxa_allocate_exception" [2023-06-22 16:09:51.485] [error] At AST node: import description [2023-06-22 16:09:51.485] [error] This may be the import of host environment like JavaScript or Golang. Please check that you've registered the necessary host modules from the host programming language. [2023-06-22 16:09:51.485] [error] At AST node: import section [2023-06-22 16:09:51.485] [error] At AST node: module docker: Error response from daemon: Others("unknown import"): unknown.Does anyone know how to fix this problem? Or maybe point me in the right direction on how to run a wasm application on a server. For the last two days I'm roaming the internet to figure out how to start the application on a server, but I just don't understand it.
Thank you very much in advance.
-
You need to copy all the files created to the server:
app.wasm
app.js
qtloader.js
qtlogo.svg
app.htmland then open the html file in a browser.
-
M MeatBerry has marked this topic as solved on
-
Thanks for the feedback. This way didn't work on the Nginx server.
However, I made it work using a docker image of a node web server.
@MeatBerry Hello. How did you do it? Could you explain the steps below?