Skip to content

Instantly share code, notes, and snippets.

@cajus
Last active October 1, 2022 14:13
Show Gist options
  • Star 5 You must be signed in to star a gist
  • Fork 4 You must be signed in to fork a gist
  • Save cajus/689eca85be257997019065979799e2f6 to your computer and use it in GitHub Desktop.
Save cajus/689eca85be257997019065979799e2f6 to your computer and use it in GitHub Desktop.
Building Qt for WebAssembly
# Get dependencies in place (example for Debian based systems)
sudo apt-get build-dep --yes qt5-default
sudo apt-get install --yes libxcb-xinerama0-dev git python cmake default-jre
# Install Emscripten
git clone https://github.com/juj/emsdk.git
cd emsdk
./emsdk install latest
./emsdk activate latest
source emsdk_env.sh
cd ..
# Build Qt
git clone -b 5.12.0 https://code.qt.io/qt/qt5.git
cd qt5
./init-repository -f --module-subset=qtbase,qtdeclarative,qtwebsockets,qtsvg,qtquickcontrols,qtquickcontrols2,qtgraphicaleffects
./configure -opensource -confirm-license -xplatform wasm-emscripten -release -static -no-feature-thread -nomake examples -no-dbus -no-ssl
make
cd ..
# Build your project
git clone https://github.com/msorvig/qt-webassembly-examples.git
cd qt-webassembly-examples/quick_controls2_gallery
../../../qt5/qtbase/bin/qmake
make
# Serve it and browse to http://localhost:8000/gallery.html
python -mSimpleHTTPServer
@kavikumarN
Copy link

kavikumarN commented Feb 22, 2019

how to add dependencies into URI?
i got an error and rectified by enabling source code option in software& updates. link

@kavikumarN
Copy link

`d_p.h:196:14: fatal error:
'x86intrin.h' file not found

include <x86intrin.h>

1 error generated.
shared:ERROR: compiler frontend failed to generate LLVM bitcode, halting
`error while running make

@AlessandroMilan
Copy link

AlessandroMilan commented Mar 24, 2019

I had the same problem and I solved it using emscripten 1.38.16. Run the commands below before building QT:

git clone https://github.com/juj/emsdk.git
cd emsdk
./emsdk install sdk-1.38.16-64bit
./emsdk activate sdk-1.38.16-64bit
source ./emsdk_env.sh

@izzaNaqvi2
Copy link

I have done all this successfully, I can not run some of the projects, for example, QT_CONTROLS2_GALLERY, it says qt quick controls 2 not installed , but they are installed already.
Plus i have a Visual Studio Project that uses QT library, i wantto run that on web assembly but i am getting error ca, someone plza guide.

@divyanshusahu
Copy link

'x86intrin.h' file not found

I solved this error by switching to qt-5.13.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment