安装 1.38.30-64bit
emsdk install sdk-fastcomp-1.38.30-64bit
激活
emsdk activate --embedded sdk-fastcomp-1.38.30-64bit
设置环境变量
emsdk_env.bat
configure -no-warnings-are-errors -xplatform wasm-emscripten -platform win32-g++ -nomake examples -prefix %CD%\qtbase
中间会有编译选择,c 是商业版本,o是开源版本。 y 遵循GNU开源协议等等。
mingw32-make启动编译,编译过程中出现错误,查看config.log发现
> makefile:156: recipe for target 'apphtml' failed
> mingw32-make: *** [apphtml] Error -1073741515
这里看config.log没思路,转而下载了5.14的版本,对应em++改为了支持单线程的1.30.27版本,再次进行configure,时间比较久。
====上面有一堆编译cpp的输出,就不贴出来了。
g++ -o "../bin/qmake.exe" main.o meta.o option.o project.o property.o ioutils.o proitems.o qmakebuiltins.o qmakeevaluator.o qmakeglobals.o qmakeparser.o qmakevfs.o pbuilder_pbx.o makefile.o makefiledeps.o metamakefile.o projectgenerator.o unixmake2.o unixmake.o mingw_make.o msbuild_objectmodel.o msvc_nmake.o msvc_objectmodel.o msvc_vcproj.o msvc_vcxproj.o winmakefile.o xmloutput.o qutfcodec.o qendian.o qglobal.o qlogging.o qmalloc.o qnumeric.o qoperatingsystemversion.o qrandom.o qabstractfileengine.o qbuffer.o qdatastream.o qdebug.o qdir.o qdiriterator.o qfile.o qfiledevice.o qfileinfo.o qfilesystemengine.o qfilesystementry.o qfsfileengine.o qfsfileengine_iterator.o qiodevice.o qsettings.o qtemporaryfile.o qtextstream.o qjsonarray.o qjson.o qjsondocument.o qjsonobject.o qjsonparser.o qjsonvalue.o qmetatype.o qsystemerror.o qvariant.o quuid.o qarraydata.o qbitarray.o qbytearray.o qbytearraylist.o qbytearraymatcher.o qcalendar.o qgregoriancalendar.o qromancalendar.o qcryptographichash.o qdatetime.o qhash.o qlist.o qlocale.o qlocale_tools.o qmap.o qregexp.o qringbuffer.o qstringbuilder.o qstring.o qstringlist.o qversionnumber.o qvsnprintf.o qxmlstream.o qxmlutils.o qfilesystemengine_win.o qfilesystemiterator_win.o qfsfileengine_win.o qlocale_win.o qsettings_win.o qoperatingsystemversion_win.o qsystemlibrary.o registry.o qlibraryinfo.o -static -s -lole32 -luuid -ladvapi32 -lkernel32 -lnetapi32 -Wl,--gc-sections
Info: creating super cache file G:\Qt\Qt5.14.2_new\5.14.2\Src\.qmake.super
Info: creating cache file G:\Qt\Qt5.14.2_new\5.14.2\Src\.qmake.cache
Info: creating stash file G:\Qt\Qt5.14.2_new\5.14.2\Src\.qmake.stash
Selecting Qt Edition.
Type 'c' if you want to use the Commercial Edition.
Type 'o' if you want to use the Open Source Edition.
Which edition of Qt do you want to use? o
This is the Qt Open Source Edition.
You are licensed to use this software under the terms of
the GNU General Public License (GPL) version 3.
Type 'G' to view the GNU General Public License version 3 (GPLv3).
Type 'y' to accept this license offer.
Type 'n' to decline this license offer.
Do you accept the terms of the license? y
Running configuration tests...
Checking for valid makespec... yes
Checking for target architecture... wasm
Checking for host architecture... i386
Checking for alloca() in alloca.h... yes
Checking for C++14 support... no
Checking for C99 support... yes
Checking for C11 support... yes
Checking for pkg-config... no
Checking for dlopen()... yes
Checking for support for split sections and linker garbage collection... no
Checking for D-Bus >= 1.2 (host)... yes
Checking for IncrediBuild... yes
Checking for udev... no
Checking for POSIX fallocate()... yes
Checking for precompiled header support... no
Checking for RDRAND instruction... no
Checking for symbol visibility support... yes
Checking for -Bsymbolic-functions support... no
Checking for Signaling NaN for doubles... yes
Checking for STL compatibility... yes
Checking for zlib... no
Checking for Zstandard... no
Checking for clock_gettime()... yes
Checking for POSIX monotonic clock... yes
Checking for C++11 ... yes
Checking for futimens()... yes
Checking for getentropy()... no
Checking for GLib... no
Checking for POSIX iconv... yes
Checking for ICU... no
Checking for inotify... no
Checking for SysV IPC... no
Checking for POSIX IPC... no
Checking for pollts()... no
Checking for poll()... yes
Checking for PCRE2... no
Checking for slog2... no
Checking for 64 bit atomics... yes
Checking for DoubleConversion... no
Checking for O_CLOEXEC... no
Checking for C++11 ... yes
Checking for working std::atomic for function pointers... yes
Checking for getifaddrs()... no
Checking for KRB5 GSSAPI Support... no
Checking for IPv6 ifname... no
Checking for OpenGL ES 2.0... yes
Checking for KMS... no
Checking for EGL... yes
Checking for FreeType... no
Checking for GBM... no
Checking for LinuxFB... no
Checking for mtdev... no
Checking for OpenGL ES 3.0... no
Checking for OpenVG... no
Checking for default QPA platform... wasm
Checking for HarfBuzz... no
Checking for libjpeg... no
Checking for libmd4c... no
Checking for tslib... no
Checking for Vulkan... no
Checking for XLib... no
Checking for xkbcommon >= 0.5.0... no
Checking for CUPS... no
Checking for DB2 (IBM)... no
Checking for InterBase... no
Checking for MySQL... no
Checking for OCI (Oracle)... no
Checking for ODBC... no
Checking for PostgreSQL... no
Checking for SQLite (version 2)... no
Checking for TDS (Sybase)... no
Checking for C++14 make_unique()... no
Checking for Direct3D 12... no
Checking for Assimp... no
Checking for SDL2... no
Checking for Autodesk FBX... no
Checking for Wayland client library... no
Checking for Wayland EGL library... no
Checking for wayland-server... no
Checking for BlueZ... no
Checking for sensorfw... no
Checking for Gypsy... no
Checking for WinRT Geolocation API... no
Checking for ALSA... no
Checking for Vivante GPU... no
Checking for GStreamer 1.0... no
Checking for GStreamer 0.10... no
Checking for Video for Linux... no
Checking for OpenAL... yes
Checking for PulseAudio >= 0.9.10... no
Checking for libresourceqt5... no
Checking for Flite... no
Checking for Speech Dispatcher... no
Checking for libclang... 系统找不到指定的路径。
no
Checking for architecture supported... no
Checking for bison... yes
Checking for python2... G:/Work/WebAssembly/emsdk_1.38.27/python/2.7.13.1_64bit/python-2.7.13.amd64/python.exe
Checking for gperf... yes
Checking for flex... yes
Checking for submodule initialized... yes
Checking for build path without whitespace... yes
Checking for host pkg-config...
Checking for jumbo build merge limit... 8
Checking for platform supported... Unknown platform. Qt WebEngine only supports Linux, Windows, and macOS.
Checking for d-bus... no
Checking for fontconfig... no
Checking for glib-2.0 >= 2.32.0... no
Checking for jsoncpp... no
Checking for khr... yes
Checking for lcms2... no
Checking for libdrm... no
Checking for libevent... no
Checking for libvpx... no
Checking for libwebp, libwebpmux and libwebpdemux... no
Checking for compatible libxml2 and libxslt... no
Checking for minizip... no
Checking for system ninja... yes
Checking for nss >= 3.26... no
Checking for opus... no
Checking for protobuf... no
Checking for re2... no
Checking for snappy... no
Checking for x11... no
Checking for xcomposite... no
Checking for xcursor... no
Checking for xi... no
Checking for xtst... no
Done running configuration tests.
Configure summary:
Building on: win32-g++ (i386, CPU features: )
Building for: wasm-emscripten (wasm, CPU features: )
Target compiler: clang 6.0.1
Configuration: cross_compile largefile release c++11 no-pkg-config reduce_exports static stl
Build options:
Mode ................................... release
Optimize release build for size ........ no
Building shared libraries .............. no
Using C standard ....................... C11
Using C++ standard ..................... C++11
Using ccache ........................... no
Relocatable ............................ no
Using precompiled headers .............. no
Using LTCG ............................. no
Target compiler supports:
Build parts ............................ libs
Qt modules and options:
Qt Concurrent .......................... no
Qt D-Bus ............................... no
Qt D-Bus directly linked to libdbus .... no
Qt Gui ................................. yes
Qt Network ............................. yes
Qt Sql ................................. no
Qt Testlib ............................. yes
Qt Widgets ............................. yes
Qt Xml ................................. yes
Support enabled for:
Using pkg-config ....................... no
udev ................................... no
Using system zlib ...................... no
Zstandard support ...................... no
Qt Core:
DoubleConversion ....................... yes
Using system DoubleConversion ........ no
GLib ................................... no
iconv .................................. yes
ICU .................................... no
Built-in copy of the MIME database ..... yes
Tracing backend ........................
Logging backends:
journald ............................. no
syslog ............................... no
slog2 ................................ no
PCRE2 .................................. yes
Using system PCRE2 ................... no
Qt Network:
getifaddrs() ........................... no
IPv6 ifname ............................ no
libproxy ............................... no
OpenSSL ................................ no
Qt directly linked to OpenSSL ........ no
OpenSSL 1.1 ............................ no
DTLS ................................... no
OCSP-stapling .......................... no
SCTP ................................... no
Use system proxies ..................... yes
GSSAPI ................................. no
Qt Gui:
Accessibility .......................... yes
FreeType ............................... yes
Using system FreeType ................ no
HarfBuzz ............................... yes
Using system HarfBuzz ................ no
Fontconfig ............................. no
Image formats:
GIF .................................. yes
ICO .................................. yes
JPEG ................................. yes
Using system libjpeg ............... no
PNG .................................. yes
Using system libpng ................ no
Text formats:
HtmlParser ........................... yes
CssParser ............................ yes
OdfWriter ............................ yes
MarkdownReader ....................... yes
Using system libmd4c ............... no
MarkdownWriter ....................... yes
EGL .................................... yes
OpenVG ................................. no
OpenGL:
Desktop OpenGL ....................... no
OpenGL ES 2.0 ........................ yes
OpenGL ES 3.0 ........................ no
OpenGL ES 3.1 ........................ no
OpenGL ES 3.2 ........................ no
Vulkan ................................. no
Session Management ..................... yes
Features used by QPA backends:
evdev .................................. no
libinput ............................... no
INTEGRITY HID .......................... no
mtdev .................................. no
tslib .................................. no
xkbcommon .............................. no
X11 specific:
XLib ................................. no
XCB Xlib ............................. no
EGL on X11 ........................... no
QPA backends:
DirectFB ............................... no
EGLFS .................................. no
LinuxFB ................................ no
VNC .................................... yes
Qt Sql:
SQL item models ........................ yes
Qt Widgets:
GTK+ ................................... no
Styles ................................. Fusion Windows
Qt PrintSupport:
CUPS ................................... no
Qt Sql Drivers:
DB2 (IBM) .............................. no
InterBase .............................. no
MySql .................................. no
OCI (Oracle) ........................... no
ODBC ................................... no
PostgreSQL ............................. no
SQLite2 ................................ no
SQLite ................................. yes
Using system provided SQLite ......... no
TDS (Sybase) ........................... no
Qt Testlib:
Tester for item models ................. yes
Qt SerialBus:
Socket CAN ............................. no
Socket CAN FD .......................... no
SerialPort Support ..................... no
Further Image Formats:
JasPer ................................. no
MNG .................................... no
TIFF ................................... yes
Using system libtiff ................. no
WEBP ................................... yes
Using system libwebp ................. no
Qt QML:
QML network support .................... yes
QML debugging and profiling support .... yes
QML just-in-time compiler .............. no
QML sequence object .................... yes
QML XML http request ................... yes
QML Locale ............................. yes
Qt QML Models:
QML list model ......................... yes
QML delegate model ..................... yes
Qt Quick:
Direct3D 12 ............................ no
AnimatedImage item ..................... yes
Canvas item ............................ yes
Support for Qt Quick Designer .......... yes
Flipable item .......................... yes
GridView item .......................... yes
ListView item .......................... yes
TableView item ......................... yes
Path support ........................... yes
PathView item .......................... yes
Positioner items ....................... yes
Repeater item .......................... yes
ShaderEffect item ...................... yes
Sprite item ............................ yes
QtQuick3D:
Assimp ................................. yes
System Assimp .......................... no
Qt Scxml:
ECMAScript data model for QtScxml ...... yes
Qt Gamepad:
SDL2 ................................... no
Qt 3D GeometryLoaders:
Autodesk FBX ........................... no
Qt Wayland Client ........................ no
Qt Wayland Compositor .................... no
Qt Bluetooth:
BlueZ .................................. no
BlueZ Low Energy ....................... no
Linux Crypto API ....................... no
Native Win32 Bluetooth ................. no
WinRT Bluetooth API (desktop & UWP) .... no
WinRT advanced bluetooth low energy API (desktop & UWP) . no
Qt Sensors:
sensorfw ............................... no
Qt Quick Controls 2:
Styles ................................. Default Fusion Imagine Material Universal
Qt Quick Templates 2:
Hover support .......................... yes
Multi-touch support .................... yes
Qt Positioning:
Gypsy GPS Daemon ....................... no
WinRT Geolocation API .................. no
Qt Location:
Qt.labs.location experimental QML plugin . yes
Geoservice plugins:
OpenStreetMap ........................ no
HERE ................................. yes
Esri ................................. yes
Mapbox ............................... yes
MapboxGL ............................. no
Itemsoverlay ......................... yes
QtXmlPatterns:
XML schema support ..................... yes
Qt Multimedia:
ALSA ................................... no
GStreamer 1.0 .......................... no
GStreamer 0.10 ......................... no
Video for Linux ........................ no
OpenAL ................................. yes
PulseAudio ............................. no
Resource Policy (libresourceqt5) ....... no
Windows Audio Services ................. no
DirectShow ............................. no
Windows Media Foundation ............... no
Qt TextToSpeech:
Flite .................................. no
Flite with ALSA ........................ no
Speech Dispatcher ...................... no
Qt Tools:
QDoc ................................... no
Qt WebEngine Build Tools:
Use System Ninja ....................... yes
Use System Gn .......................... no
Jumbo Build Merge Limit ................ 8
Developer build ........................ no
QtWebEngine required system libraries:
fontconfig ........................... no
dbus ................................. no
nss .................................. no
khr .................................. yes
glibc ................................ no
Optional system libraries used:
re2 .................................. no
icu .................................. no
libwebp, libwebpmux and libwebpdemux . no
opus ................................. no
ffmpeg ............................... no
libvpx ............................... no
snappy ............................... no
glib ................................. no
zlib ................................. no
minizip .............................. no
libevent ............................. no
jsoncpp .............................. no
protobuf ............................. no
libxml2 and libxslt .................. no
lcms2 ................................ no
png .................................. no
JPEG ................................. no
harfbuzz ............................. no
freetype ............................. no
Note: Using static linking will disable the use of dynamically
loaded plugins. Make sure to import all needed static plugins,
or compile needed modules into the library.
Note: No wayland-egl support detected. Cross-toolkit compatibility disabled.
Note: The following modules are not being compiled in this configuration:
serialport
3dcore
3drender
webenginecore
webengine
webenginewidgets
WARNING: QDoc will not be compiled, probably because libclang could not be located. This means that you cannot build the Qt documentation.
Either ensure that llvm-config is in your PATH environment variable, or set LLVM_INSTALL_DIR to the location of your llvm installation.
On Linux systems, you may be able to install libclang by installing the libclang-dev or libclang-devel package, depending on your distribution.
On macOS, you can use Homebrew's llvm package.
On Windows, you must set LLVM_INSTALL_DIR to the installation path.
WARNING: Unknown platform. Qt WebEngine only supports Linux, Windows, and macOS.
WARNING: QtWebEngine will not be built.
WARNING: QtPdf will not be built.
Qt is now configured for building. Just run 'mingw32-make'.
Once everything is built, Qt is installed.
You should NOT run 'mingw32-make install'.
Note that this build cannot be deployed to other machines or devices.
Prior to reconfiguration, make sure you remove any leftovers from
the previous build.
这里说需要配置llvm-config路径,暂时没配置。按照官方教程直接make,发现make不识别。所以根据上述提示,执行mingw32-make,发现ok
mingw32-make module-qtbase
这一步要等比较长时间。
编译报错了!
In file included from G:/Qt/Qt5.14.2_new/5.14.2/Src/qtbase/include/QtCore/qglobal.h:1:0,
from G:/Qt/Qt5.14.2_new/5.14.2/Src/qtbase/include/QtCore/../../src/corelib/text/qchar.h:43,
from G:/Qt/Qt5.14.2_new/5.14.2/Src/qtbase/include/QtCore/qchar.h:1,
from G:/Qt/Qt5.14.2_new/5.14.2/Src/qtbase/include/QtCore/../../src/corelib/text/qstring.h:49,
from G:/Qt/Qt5.14.2_new/5.14.2/Src/qtbase/include/QtCore/qstring.h:1,
from G:/Qt/Qt5.14.2_new/5.14.2/Src/qtbase/include/QtCore/../../src/corelib/io/qdir.h:43,
from G:/Qt/Qt5.14.2_new/5.14.2/Src/qtbase/include/QtCore/qdir.h:1,
from G:/Qt/Qt5.14.2_new/5.14.2/Src/qtbase/src/corelib/global/qlibraryinfo.cpp:41:
G:/Qt/Qt5.14.2_new/5.14.2/Src/qtbase/include/QtCore/../../src/corelib/global/qglobal.h:86:30: error: division by zero in #if
#define QT_CONFIG(feature) (1/QT_FEATURE_##feature == 1)
^
G:/Qt/Qt5.14.2_new/5.14.2/Src/qtbase/src/corelib/global/qlibraryinfo.cpp:676:7: note: in expansion of macro 'QT_CONFIG'
#elif QT_CONFIG(relocatable)
^
makefile:336: recipe for target 'qlibraryinfo_final.o' failed
mingw32-make[3]: *** [qlibraryinfo_final.o] Error 1
mingw32-make[3]: Leaving directory 'G:/Qt/Qt5.14.2_new/5.14.2/Src/qtbase/qmake'
Makefile.qmake-aux:261: recipe for target 'G:/Qt/Qt5.14.2_new/5.14.2/Src/qtbase/qmake/qmake.exe' failed
mingw32-make[2]: *** [G:/Qt/Qt5.14.2_new/5.14.2/Src/qtbase/qmake/qmake.exe] Error 2
mingw32-make[2]: Leaving directory 'G:/Qt/Qt5.14.2_new/5.14.2/Src/qtbase/qmake'
Makefile:125: recipe for target 'sub-qmake-qmake-aux-pro-make_first' failed
mingw32-make[1]: *** [sub-qmake-qmake-aux-pro-make_first] Error 2
mingw32-make[1]: Leaving directory 'G:/Qt/Qt5.14.2_new/5.14.2/Src/qtbase'
makefile:84: recipe for target 'module-qtbase' failed
mingw32-make: *** [module-qtbase] Error 2
从错误地方看,是因为QT_CONFIG(relocatable)这个宏执行时候,QT_FEATURE##feature为0了,进到qglobal.h中看到有这么一句注释
/*
The QT_CONFIG macro implements a safe compile time check for features of Qt.
Features can be in three states:
0 or undefined: This will lead to a compile error when testing for it
-1: The feature is not available
1: The feature is available
*/
看来是没定义,那么我们在qlibraryinfo.cpp中,加上这个宏定义是不是就可以了?试一下,qlibraryinfo.cpp中添加#include “qconfig_p.h”然后继续执行 mingw32-make,稍等片刻,很顺利,编译过了。
编译demo
执行qtbase下面的qmake qtbase\bin\qmake E:\GitPro\qt-webassembly-examples\widgets_wiggly\widgets_wiggly.pro
执行 mingw32-make
最后发现文件生成在了G:\Qt\Qt5.14.2\5.14.2\Src目录下:
widgets_wiggly.js
widgets_wiggly.wasm
widgets_wiggly.html
qt WebAssembly对汇编的支持情况
参考文章
https://www.jianshu.com/p/3ef1dfabab68
https://forum.qt.io/topic/107137/qt-for-webassembly-on-windows-10/2