QtCreator cannot find the emscripten compiler
Asked Answered
G

3

5

I followed this guide and installed emscripten using emsdk and activated it.Then I configured my $PATH as instructed by the emsdk itself and also sourced emsdk-master/emsdk_env.sh.Now I can access both emcc and em++ in the terminal.The file ~/.emscripten is also present(this is the file that QtCreator will fetch to find the path of compilers for WASM).

The WebAssembly kit for Qt also has been installed by the Qt Maintenance Tool.

Now in the Kit configuration in the QtCreator I get this(QtCreator is opened via terminal after sourcing emsdk_env.sh):

enter image description here

It cannot determine the path of compilers by itself.

In the Compilers tab I manually added a compiler as follows:

enter image description here

But I get this error in the Kits tab after that:

enter image description here

What does that mean? What did I skip? Does anybody ever have the experience of doing this?

Also changing the compiler from em++ to wasm-32-wasi-clang++ or clang++ doesn't change anything.

enter image description here

By the way if I use that kit I get:

Error while parsing file whatever.pro. Giving up.
Project ERROR: Cannot run target compiler 'em++'. Output:
===================
===================
Maybe you forgot to setup the environment?

And please don't tell me that this question is the duplicate of this because it isn't(mine has more details) and there's no useful answer for that after 9 months at this time.

Any help is much appreciated.

Gaming answered 30/8, 2020 at 6:2 Comment(6)
I'm having the same problem, and so far it seems that Qt Creator is not getting the sourced environment, even thought it was started from a shell where 'source emsdk_env.sh' was run. The error ("... Maybe you forgot to setup the environment?") is exacly what /path/to/Qt/wasm_32/bin/qmake says when you have forgot to source, and in Qt Creator's 'General Messages' log, there is "shared:ERROR: BINARYEN_ROOT is set to empty value in .emscripten", which is what /path/to/emscripten/em++ says when you forgot to source. I can successfully build a wasm app with qmake from command line.Mady
Thanks for the reply @foolo.I tried running the WASM qmake for my project and got the warning about version incompatibility between the emsdk which was used by Qt 5.14(1.38.27) and the emsdk currently installed(2.0.0 i,e latest).So I deleted the emsdk entirely and began from scratch,this time by installing 1.38.27 and got this.Not sure what's causing that.How did you manage to build a project successfully?Gaming
So far I only built one of Qt's sample applications. I installed Qt 5.15 and Creator with the installer from qt.io/download-qt-installer and emsdk 1.39.8 from the repo. Then navigated to the project (~/Qt/Examples/Qt-5.15.0/widgets/mainwindows) and ran ~/Qt/wasm_32/bin/qmake and make. It created web files in sdi folder. I tested it with ~/emsdk/upstream/emscripten/emrun --browser=firefox sdi/sdi.html which actually runs the text editor in the browser :) I created a gist with detailed steps here: gist.github.com/foolo/a728e971bdd79b37fff04ca8b65b847cMady
@Mady I got Qt/5.14.2/wasm_32/include/QtCore/qcompilerdetection.h:591:6: error: Qt requires a C++11 compiler and yours does not seem to be that besides lots of other strange errors like error: unknown type name 'constexpr' for that example project.After adding CONFIG+=c++11 that error turned into Failed to run llvm optimizations: like this.Needless to say I sourced emsdk_env.sh beforehand.Any idea? Should I upgrade my Qt or start from scratch?Gaming
It seems that you are using Qt 5.14 and emsdk 1.38.27 fastcomp clang, which should be a good combo according to wiki.qt.io/Qt_for_WebAssembly, but maybe the error is still related to that combo. I'm using Qt 5.15 and emsdk 1.39.8, so my only advice would be to try the newer version.Mady
check my comment on a similar issue. It might helpTaught
T
1

You have to setup the emsdk inside QtCreator => Preferences => Devices => WebAssembly. Afterwards the compiler should be auto-detected by Qt Creator.

enter image description here

Thirzia answered 23/6, 2022 at 12:29 Comment(0)
H
0

Make sure you run:
emsdk install
and
emsdk activate
within emsdk folder, not from a relative path.

Haemagglutinate answered 12/6, 2022 at 23:33 Comment(0)
S
0

I had the same problem and the solution was, that python was not correctly recognized. In my case the symbolic link /usr/bin/python was not set ln -sf /usr/bin/python3 /usr/bin/python Afterwards the emsripten Toolchain is recognized automatically in QtCreator.

Swaraj answered 26/8, 2022 at 12:6 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.