Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

xmake不支持Qt 6 on WASM #4137

Closed
da-liii opened this issue Aug 28, 2023 · 39 comments
Closed

xmake不支持Qt 6 on WASM #4137

da-liii opened this issue Aug 28, 2023 · 39 comments

Comments

@da-liii
Copy link
Member

da-liii commented Aug 28, 2023

Xmake 版本

dev

操作系统版本和架构

Ubuntu 22.04

描述问题

xmake可以构建Qt 6 on WASM的项目,但是使用浏览器打开会直接报错

关键问题可能是,如下代码没有为Qt 6做适配

-- define rule: qt/wasm application
rule("qt._wasm_app")
add_deps("qt.env")
after_build(function (target)
local qt = target:data("qt")
local pluginsdir = qt and qt.pluginsdir
if pluginsdir then
local targetdir = target:targetdir()
local htmlfile = path.join(targetdir, target:basename() .. ".html")
if os.isfile(path.join(pluginsdir, "platforms/wasm_shell.html")) then
os.vcp(path.join(pluginsdir, "platforms/wasm_shell.html"), htmlfile)
io.gsub(htmlfile, "@APPNAME@", target:name())
os.vcp(path.join(pluginsdir, "platforms/qtloader.js"), targetdir)
os.vcp(path.join(pluginsdir, "platforms/qtlogo.svg"), targetdir)
end
end
end)

如下代码可能是关键的构建参数:
https://github.com/qt/qtbase/blob/v6.5.2/cmake/QtWasmHelpers.cmake#L20-L27

期待的结果

能够正常运行

工程配置

https://github.com/XmacsLabs/xmake-qt-wasm

附加信息和错误日志

这是在浏览器调试终端里面的报错

ReferenceError: createQtAppInstance is not defined
    at completeLoadEmscriptenModule (qtloader.js:462:9)
    at qtloader.js:345:13

The qtContainerElements module property was not set or is invalid. Proceeding with no screens.

no screens available, assuming 24-bit color
@da-liii da-liii added the bug label Aug 28, 2023
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Title: xmake does not support Qt 6 on WASM

@waruqi
Copy link
Member

waruqi commented Aug 29, 2023

再试试,不行就自己参考着这个位置 自己调整下 改改。。#4138

xmake update -s github:xmake-io/xmake#qtwasm

@da-liii
Copy link
Member Author

da-liii commented Aug 29, 2023

只是加这两个参数,我已经试过。支持 Qt 6 的 wasm port,整体上没这么简单,需要不少工作量

target:add("ldflags", "-s MODULARIZE=1", "-s EXPORT_NAME=createQtAppInstance")

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Just add these two parameters, I have tried. Need to support the wasm port of Qt 6, which is not so simple on the whole and requires a lot of work

target:add("ldflags", "-s MODULARIZE=1", "-s EXPORT_NAME=createQtAppInstance")

@waruqi
Copy link
Member

waruqi commented Aug 29, 2023

只是加这两个参数,我已经试过。支持 Qt 6 的 wasm port,整体上没这么简单,需要不少工作量

target:add("ldflags", "-s MODULARIZE=1", "-s EXPORT_NAME=createQtAppInstance")

刚的 patch 就是加了,不行么?

我暂时没有 qt6 wasm 环境

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Just add these two parameters, I have tried. The wasm port that supports Qt 6 is not so simple as a whole and requires a lot of work

target:add("ldflags", "-s MODULARIZE=1", "-s EXPORT_NAME=createQtAppInstance")

Just added the patch, can't it?

I don't have a qt6 wasm environment for now

@da-liii
Copy link
Member Author

da-liii commented Aug 29, 2023

加了这两个参数之后,xmake build会出错,错误如下:

$ xmake build -vD
/home/da/.xmake/packages/e/emscripten/3.1.25/79e74f9c8c4c43e8a2361e27d1d19f32/upstream/emscripten/em++ -o build/wasm/wasm32/release/app.html build/.objs/app/wasm/wasm32/release/src/main.cpp.o build/.objs/app/wasm/wasm32/release/build/.qt/plugin/app/static_import.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickShapesPrivate_resources_2/.rcc/qrc_qtquickshapes_shaders.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/Help_resources_1/.rcc/qrc_helpsystem.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/ExampleIconsPrivate_resources_1/.rcc/qrc_example_icons.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/qtquickcontrols2plugin_resources_1/.rcc/qrc_indirectBasic.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickParticlesPrivate_resources_7/.rcc/qrc_particles_shaders5.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickParticlesPrivate_resources_8/.rcc/qrc_particles_shaders6.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/qtquickcontrols2fusionstyleplugin_resources_3/.rcc/qrc_qtquickcontrols2fusionstyle.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickDialogs2QuickImpl_resources_3/.rcc/qrc_QuickDialogs2QuickImpl.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QWasmIntegrationPlugin_resources_1/.rcc/qrc_wasmfonts.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/qtquickcontrols2imaginestyleplugin_resources_3/.rcc/qrc_qmake_qtquickcontrols2imaginestyleplugin.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickEffectsPrivate_resources_2/.rcc/qrc_effects.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickDialogs2QuickImpl_resources_4/.rcc/qrc_QuickDialogs2QuickImplShaders.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/Widgets_resources_1/.rcc/qrc_qstyle.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/PrintSupport_resources_2/.rcc/qrc_qprintdialog1.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/qtquickcontrols2materialstyleplugin_resources_4/.rcc/qrc_qtquickcontrols2materialstyleplugin_shaders.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/PrintSupport_resources_1/.rcc/qrc_qprintdialog.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/qtquickcontrols2basicstyleplugin_resources_3/.rcc/qrc_qtquickcontrols2basicstyleplugin.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/Quick_resources_2/.rcc/qrc_scenegraph_shaders.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/Widgets_resources_3/.rcc/qrc_qmessagebox.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickParticlesPrivate_resources_6/.rcc/qrc_particles_shaders4.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickParticlesPrivate_resources_4/.rcc/qrc_particles_shaders2.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/Gui_resources_1/.rcc/qrc_qpdf.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QmlCompilerPrivate_resources_1/.rcc/qrc_builtins.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/Widgets_resources_2/.rcc/qrc_qstyle1.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/qtquickcontrols2imaginestyleimplplugin_resources_3/.rcc/qrc_qtquickcontrols2imaginestyleimplplugin_shaders.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickParticlesPrivate_resources_3/.rcc/qrc_particles_shaders1.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickParticlesPrivate_resources_2/.rcc/qrc_particles.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/Gui_resources_2/.rcc/qrc_gui_shaders.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickParticlesPrivate_resources_5/.rcc/qrc_particles_shaders3.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/qtquickcontrols2universalstyleplugin_resources_3/.rcc/qrc_qtquickcontrols2universalstyleplugin.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/Qml_resources_2/.rcc/qrc_qmlMetaQmldir.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QWasmIntegrationPlugin_resources_2/.rcc/qrc_wasmwindow.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/qtquickcontrols2materialstyleplugin_resources_3/.rcc/qrc_qtquickcontrols2materialstyleplugin.cpp.o -L/home/da/6.5.2/wasm_singlethread/plugins/platforms -L/home/da/6.5.2/wasm_singlethread/lib -O3 -lqwasm -lQt6OpenGL -lQt6Gui -lQt6Widgets -lQt6Core -lQt6BundledLibjpeg -lQt6BundledHarfbuzz -lQt6BundledZLIB -lQt6BundledFreetype -lQt6BundledPcre2 -lQt6BundledLibpng -s WASM=1 -s FETCH=1 -s FULL_ES2=1 -s FULL_ES3=1 -s USE_WEBGL2=1 --bind -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s EXTRA_EXPORTED_RUNTIME_METHODS=[\"UTF16ToString\",\"stringToUTF16\"] -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s EXPORT_NAME=createQtAppInstance
em++: warning: EXTRA_EXPORTED_RUNTIME_METHODS is deprecated, please use EXPORTED_RUNTIME_METHODS instead [-Wdeprecated]
em++: error: Customizing EXPORT_NAME requires that the HTML be customized to use that name (see https://github.com/emscripten-core/emscripten/issues/10086)

具体的构建命令应该需要改一下。See emscripten-core/emscripten#10086

@da-liii
Copy link
Member Author

da-liii commented Aug 29, 2023

这块具体的思路应该是,先用cmake搞定qt 6 on wasm的构建,然后在xmake里面复刻cmake里面的构建参数

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


After adding these two parameters, xmake build will make an error, the error is as follows:

$ xmake build -vD
/home/da/.xmake/packages/e/emscripten/3.1.25/79e74f9c8c4c43e8a2361e27d1d19f32/upstream/emscripten/em++ -o build/wasm/wasm32/release/app.html build/.objs/app/wasm/wasm32/release /src/main.cpp.o build/.objs/app/wasm/wasm32/release/build/.qt/plugin/app/static_import.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects- Release/QuickShapesPrivate_resources_2/.rcc/qrc_qtquickshapes_shaders.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/Help_resources_1/.rcc/qrc_helpsystem.cpp.o /home/da/6.5.2/wasm_singlethread/ lib/objects-Release/ExampleIconsPrivate_resources_1/.rcc/qrc_example_icons.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/qtquickcontrols2plugin_resources_1/.rcc/qrc_indirectBasic.cpp.o /home/da/6 .5. 2/wasm_singlethread/lib/objects-Release/QuickParticlesPrivate_resources_7/.rcc/qrc_particles_shaders5.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickParticlesPrivate_resources_8/.rcc/qrc_particles_shaders6 .cpp.o /home/ da/6.5.2/wasm_singlethread/lib/objects-Release/qtquickcontrols2fusionstyleplugin_resources_3/.rcc/qrc_qtquickcontrols2fusionstyle.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickDialogs2QuickImpl _resources_3/.rcc/qrc_QuickDialogs2QuickImpl.cpp. o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QWasmIntegrationPlugin_resources_1/.rcc/qrc_wasmfonts.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/qtquickcontrols2imaginestyleplugin_resources_3 /.rcc/ qrc_qmake_qtquickcontrols2imaginestyleplugin.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickEffectsPrivate_resources_2/.rcc/qrc_effects.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects- Release/QuickDialogs2QuickImpl_resources_4 /.rcc/qrc_QuickDialogs2QuickImplShaders.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/Widgets_resources_1/.rcc/qrc_qstyle.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects -Release/PrintSupport_resources_2/.rcc/qrc_qprintdialog1.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/qtquickcontrols2materialstyleplugin_resources_4/.rcc/qrc_qtquickcontrols2materialstyleplugin_shaders.cpp.o /home/da/6.5.2/wasm_singlethread /lib/objects-Release/PrintSupport_resources_1/.rcc/qrc_qprintdialog.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/qtquickcontrols2basicstyleplugin_resources_3/.rcc/qrc_qtquickcontrols2basicstyleplugin.cpp .o /home/da/6.5 .2/wasm_singlethread/lib/objects-Release/Quick_resources_2/.rcc/qrc_scenegraph_shaders.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/Widgets_resources_3/.rcc/qrc_qmessagebox.cpp.o /home /da/6.5.2/wasm_singlethread/lib/objects-Release/QuickParticlesPrivate_resources_6/.rcc/qrc_particles_shaders4.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickParticlesPrivate_resources_4/.rcc/qrc_partic les_shaders2.cpp .o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/Gui_resources_1/.rcc/qrc_qpdf.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QmlCompilerPrivate_resources_1/.rcc /qrc_builtins.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/Widgets_resources_2/.rcc/qrc_qstyle1.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/ qtquickcontrols2imaginestyleimplplugin_resources_3/.rcc/qrc_qtquickcontrols2imaginestyleimplplugin_shaders.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QuickParticlesPrivate_resources_3/.rcc/qrc_particles_shaders 1.cpp.o /home/da/6.5.2/wasm_singlethread/lib/ objects-Release/QuickParticlesPrivate_resources_2/.rcc/qrc_particles.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/Gui_resources_2/.rcc/qrc_gui_shaders.cpp.o /home/da/6.5.2/ wasm_singlethread/lib/objects-Release/QuickParticlesPrivate_resources_5/.rcc/qrc_particles_shaders3.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/qtquickcontrols2universalstyleplugin_resources_3/.rcc/qrc_qt quickcontrols2universalstyleplugin.cpp.o /home/da/ 6.5.2/wasm_singlethread/lib/objects-Release/Qml_resources_2/.rcc/qrc_qmlMetaQmldir.cpp.o /home/da/6.5.2/wasm_singlethread/lib/objects-Release/QWasmIntegrationPlugin_resources_2/.rcc/qrc_wasmwindow.cpp.o / home/da/6.5.2/wasm_singlethread/lib/objects-Release/qtquickcontrols2materialstyleplugin_resources_3/.rcc/qrc_qtquickcontrols2materialstyleplugin.cpp.o -L/home/da/6.5.2/wasm_singlethread/plugins/platforms -L/home/da/6 .5 .2/wasm_singlethread/lib -O3 -lqwasm -lQt6OpenGL -lQt6Gui -lQt6Widgets -lQt6Core -lQt6BundledLibjpeg -lQt6BundledHarfbuzz -lQt6BundledZLIB -lQt6BundledFreetype -lQt6BundledPcre2 -lQt6BundledLibpng -s WASM=1 -s FETCH=1 -s FULL_ES2=1 -s FULL_ES3=1 -s USE_WEBGL2=1 --bind -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s EXTRA_EXPORTED_RUNTIME_METHODS=[\"UTF16ToString\",\"stringToUTF16\"] -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s EXPORT_NAME=create QtAppInstance
em++: warning: EXTRA_EXPORTED_RUNTIME_METHODS is deprecated, please use EXPORTED_RUNTIME_METHODS instead [-Wdeprecated]
em++: error: Customizing EXPORT_NAME requires that the HTML be customized to use that name (see https://github.com/emscripten-core/emscripten/issues/10086)

The specific build command should need to be changed. See emscripten-core/emscripten#10086

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


The specific idea should be to first use cmake to build qt 6 on wasm, and then copy the build parameters in cmake in xmake

@waruqi
Copy link
Member

waruqi commented Aug 31, 2023

wasm-ld: error: duplicate symbol: qInitResources_shaders()
>>> defined in D:\\projects\\personal\\Qt\\6.2.0\\wasm_32\\lib\\objects-RelWithDebInfo\\DataVisualization_resources_1\\.rcc\\qrc_shaders.cpp.o
>>> defined in D:\\projects\\personal\\Qt\\6.2.0\\wasm_32\\lib\\objects-RelWithDebInfo\\Multimedia_resources_1\\.rcc\\qrc_shaders.cpp.o

wasm-ld: error: duplicate symbol: qCleanupResources_shaders()
>>> defined in D:\\projects\\personal\\Qt\\6.2.0\\wasm_32\\lib\\objects-RelWithDebInfo\\DataVisualization_resources_1\\.rcc\\qrc_shaders.cpp.o
>>> defined in D:\\projects\\personal\\Qt\\6.2.0\\wasm_32\\lib\\objects-RelWithDebInfo\\Multimedia_resources_1\\.rcc\\qrc_shaders.cpp.o
em++: error: 'D:/projects/personal/emsdk/upstream/bin\wasm-ld.exe @C:\Users\WANGRU~1\AppData\Local\Temp\emscripten_ky9pc162.rsp.utf-8' failed (returned 1)
error: execv(D:\projects\personal\emsdk\upstream\emscripten\em++.bat @C:\Users\WANGRU~1\AppData\Local\Temp\.xmake\230831\_443CA787EDDA451F81DE0A41ECD61BF1.args.txt) failed(1)

还有这块也有问题,D:\projects\personal\Qt\6.2.0\wasm_32\lib\objects-RelWithDebInfo 这里面的 objects 不能全部加,有冲突,但是具体怎么选择哪些 objects ,暂时还不清楚规则

@waruqi
Copy link
Member

waruqi commented Sep 1, 2023

现在就这个问题了,感觉像是 qt 和 emcc 的版本不一致导致 emscripten-core/emscripten#18409

wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\plugins\platforms\libqwasm.a(qwasmclipboard.cpp.o): undefined symbol: std::__2::__basic_string_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\plugins\platforms\libqwasm.a(qwasmclipboard.cpp.o): undefined symbol: std::__2::__basic_string_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Core.a(qurlidna.cpp.o): undefined symbol: std::__2::__basic_string_common<true>::__throw_out_of_range() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\plugins\platforms\libqwasm.a(qwasmclipboard.cpp.o): undefined symbol: std::__2::__basic_string_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
wasm-ld: error: D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a(qtextengine.cpp.o): undefined symbol: std::__2::__vector_base_common<true>::__throw_length_error() const
em++: error: 'D:/projects/personal/emsdk/upstream/bin\wasm-ld.exe -o build\wasm\wasm32\release\app.wasm build\.objs\app\wasm\wasm32\release\src\main.cpp.o build\.objs\app\wasm\wasm32\release\build\.qt\plugin\app\static_import.cpp.o D:\projects\personal\Qt\6.2.0\wasm_32\lib\objects-RelWithDebInfo\Gui_resources_1\.rcc\qrc_qpdf.cpp.o D:\projects\personal\Qt\6.2.0\wasm_32\lib\objects-RelWithDebInfo\Widgets_resources_1\.rcc\qrc_qstyle.cpp.o D:\projects\personal\Qt\6.2.0\wasm_32\lib\objects-RelWithDebInfo\Widgets_resources_2\.rcc\qrc_qstyle1.cpp.o D:\projects\personal\Qt\6.2.0\wasm_32\lib\objects-RelWithDebInfo\Widgets_resources_3\.rcc\qrc_qmessagebox.cpp.o -LD:\projects\personal\Qt\6.2.0\wasm_32\plugins\platforms -LD:\projects\personal\Qt\6.2.0\wasm_32\lib D:\projects\personal\Qt\6.2.0\wasm_32\plugins\platforms\libqwasm.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6OpenGL.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Gui.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Widgets.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6Core.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6BundledFreetype.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6BundledGlslang_Glslang.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6BundledGlslang_Oglcompiler.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6BundledGlslang_Osdependent.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6BundledGlslang_Spirv.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6BundledHarfbuzz.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6BundledLibpng.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6BundledOpenwnn.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6BundledPcre2.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6BundledPinyin.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6BundledSpirv_Cross.a D:\projects\personal\Qt\6.2.0\wasm_32\lib\libQt6BundledTcime.a -LD:\projects\personal\emsdk\upstream\emscripten\cache\sysroot\lib\wasm32-emscripten --whole-archive -lfetch -lembind-rtti --no-whole-archive -lGL-webgl2-full_es3 -lal -lhtml5 -lstubs -lnoexit -lc -ldlmalloc -lcompiler_rt -lc++ -lc++abi -lsockets -mllvm -combiner-global-alias-analysis=false -mllvm -enable-emscripten-cxx-exceptions -mllvm -enable-emscripten-sjlj -mllvm -disable-lsr C:\Users\WANGRU~1\AppData\Local\Temp\tmpmo2_hb12libemscripten_js_symbols.so --strip-debug --export-if-defined=main --export-if-defined=__start_em_asm --export-if-defined=__stop_em_asm --export-if-defined=__start_em_lib_deps --export-if-defined=__stop_em_lib_deps --export-if-defined=__start_em_js --export-if-defined=__stop_em_js --export-if-defined=__main_argc_argv --export=stackSave --export=stackRestore --export=stackAlloc --export=__errno_location --export=__get_temp_ret --export=__set_temp_ret --export=__cxa_is_pointer_type --export=__cxa_can_catch --export=__cxa_increment_exception_refcount --export=__cxa_decrement_exception_refcount --export=setThrew --export=__cxa_free_exception --export=__wasm_call_ctors --export-table -z stack-size=65536 --initial-memory=16777216 --no-entry --max-memory=2147483648 --global-base=1024' failed (returned 1)

@da-liii
Copy link
Member Author

da-liii commented Sep 1, 2023

我用最新的代码试了一下,下面这个问题还是存在的:(我的Qt 6版本和emcc是统一的)

em++: error: Customizing EXPORT_NAME requires that the HTML be customized to use that name (see https://github.com/emscripten-core/emscripten/issues/10086)

Qt 6.5, 6.4这两个大版本对应的emcc版本我都已经提交到xrepo

@waruqi
Copy link
Member

waruqi commented Sep 4, 2023

emscripten-core/emscripten@b584012
https://github.com/emscripten-core/emscripten/pull/10105/files

if shared.Settings.EXPORT_NAME != 'Module':
exit_with_error('Customizing EXPORT_NAME is not currently possible with HTML output (see emscripten-core/emscripten#10086)')

我大概明白嘞,就是 Qt 的 js 用了 createQtAppInstance , 所以得指定 EXPORT_NAME=createQtAppInstance

但是 emcc 目前的处理逻辑就是,如果你指定了 EXPORT_NAME ,那就不可能支持输出 html,只能输出 js ,然后用户自定义 html 才行。。

也就是说,要兼容 6.0 的 Qt wasm 支持,默认的编译输出,只能切到 .js 层输出。。

C:\Users\wangrunqing\Downloads\xmake-qt-wasm-main\xmake-qt-wasm-main>xmake -rv
[ 20%]: cache compiling.release src\main.cpp
D:\projects\personal\emsdk\upstream\emscripten\emcc.bat -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -IC:\Users\wangrunqing\Downloads\xmake-qt-wasm-main\xmake-qt-wasm-main\build\.gens\app\wasm\wasm32\release\rules\qt\ui -DQT_NO_DEBUG -DQT_DEPRECATED_WARNINGS -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_CORE_LIB -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtOpenGL -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtOpenGL\6.5.0 -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtOpenGL\6.5.0\QtOpenGL -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtGui -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtGui\6.5.0 -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtGui\6.5.0\QtGui -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtWidgets -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtWidgets\6.5.0 -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtWidgets\6.5.0\QtWidgets -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtCore -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtCore\6.5.0 -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtCore\6.5.0\QtCore -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\mkspecs\wasm-emscripten -DNDEBUG -fPIC -o build\.objs\app\wasm\wasm32\release\src\main.cpp.o src\main.cpp
[ 20%]: cache compiling.release build\.qt\plugin\app\static_import.cpp
D:\projects\personal\emsdk\upstream\emscripten\emcc.bat -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -IC:\Users\wangrunqing\Downloads\xmake-qt-wasm-main\xmake-qt-wasm-main\build\.gens\app\wasm\wasm32\release\rules\qt\ui -DQT_NO_DEBUG -DQT_DEPRECATED_WARNINGS -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_CORE_LIB -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtOpenGL -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtOpenGL\6.5.0 -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtOpenGL\6.5.0\QtOpenGL -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtGui -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtGui\6.5.0 -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtGui\6.5.0\QtGui -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtWidgets -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtWidgets\6.5.0 -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtWidgets\6.5.0\QtWidgets -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtCore -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtCore\6.5.0 -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include\QtCore\6.5.0\QtCore -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\include -isystem D:\projects\personal\Qt\6.5.0\wasm_singlethread\mkspecs\wasm-emscripten -DNDEBUG -fPIC -o build\.objs\app\wasm\wasm32\release\build\.qt\plugin\app\static_import.cpp.o build\.qt\plugin\app\static_import.cpp
[ 60%]: linking.release app.js
D:\projects\personal\emsdk\upstream\emscripten\em++.bat -o build\wasm\wasm32\release\app.js build\.objs\app\wasm\wasm32\release\src\main.cpp.o build\.objs\app\wasm\wasm32\release\build\.qt\plugin\app\static_import.cpp.o D:\projects\personal\Qt\6.5.0\wasm_singlethread\lib\objects-Release\Gui_resources_1\.rcc\qrc_qpdf.cpp.o D:\projects\personal\Qt\6.5.0\wasm_singlethread\lib\objects-Release\Gui_resources_2\.rcc\qrc_gui_shaders.cpp.o D:\projects\personal\Qt\6.5.0\wasm_singlethread\lib\objects-Release\Widgets_resources_1\.rcc\qrc_qstyle.cpp.o D:\projects\personal\Qt\6.5.0\wasm_singlethread\lib\objects-Release\Widgets_resources_2\.rcc\qrc_qstyle1.cpp.o D:\projects\personal\Qt\6.5.0\wasm_singlethread\lib\objects-Release\Widgets_resources_3\.rcc\qrc_qmessagebox.cpp.o -LD:\projects\personal\Qt\6.5.0\wasm_singlethread\plugins\platforms -LD:\projects\personal\Qt\6.5.0\wasm_singlethread\lib -O3 -lqwasm -lQt6OpenGL -lQt6Gui -lQt6Widgets -lQt6Core -lQt6BundledFreetype -lQt6BundledGlslang_Glslang -lQt6BundledGlslang_Oglcompiler -lQt6BundledGlslang_Osdependent -lQt6BundledGlslang_Spirv -lQt6BundledHarfbuzz -lQt6BundledLibjpeg -lQt6BundledLibpng -lQt6BundledOpenwnn -lQt6BundledPcre2 -lQt6BundledPhysX -lQt6BundledResonanceAudio -lQt6BundledSpirv_Cross -lQt6BundledTcime -lQt6BundledZLIB -s WASM=1 -s FETCH=1 -s FULL_ES2=1 -s FULL_ES3=1 -s USE_WEBGL2=1 --bind -fexceptions -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s EXPORTED_RUNTIME_METHODS=[\"UTF16ToString\",\"stringToUTF16\"] -s ALLOW_MEMORY_GROWTH=1
> copy D:\projects\personal\Qt\6.5.0\wasm_singlethread\plugins\platforms\wasm_shell.html to build\wasm\wasm32\release\app.html
> copy D:\projects\personal\Qt\6.5.0\wasm_singlethread\plugins\platforms\qtloader.js to build\wasm\wasm32\release
> copy D:\projects\personal\Qt\6.5.0\wasm_singlethread\plugins\platforms\qtlogo.svg to build\wasm\wasm32\release
[100%]: build ok, spent 78.063s

我临时改成 .js 输出就可以了

@waruqi
Copy link
Member

waruqi commented Sep 4, 2023

改了下,再试试

xmake update -s github:xmake-io/xmake#qtwasm

@waruqi waruqi added this to the v2.8.3 milestone Sep 4, 2023
@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Change it and try again

xmake update -s github:xmake-io/xmake#qtwasm

@da-liii
Copy link
Member Author

da-liii commented Sep 4, 2023

现在能够编译了,但是在浏览器里面打开报错如下:

TypeError: Cannot set properties of undefined (setting '!qtcanvas_7737680')
    at __emval_set_property (eval at completeLoadEmscriptenModule (qtloader.js:461:9), <anonymous>:9:94584)
    at app.wasm:0x4c0580
    at app.wasm:0x4c22c4
    at app.wasm:0x67de2b
    at app.wasm:0x7745a0
    at app.wasm:0x38ddcd
    at app.wasm:0x5b0d45
    at app.wasm:0x6bd46a
    at app.wasm:0x872f53
    at Module._main (eval at completeLoadEmscriptenModule (qtloader.js:461:9), <anonymous>:9:243663)

生成的源代码里面是这样的:

<div id="qt-screen-7737680" class="qt-screen"></div>

感觉是 qt-screen-7737680qtcanvas_7737680不匹配的问题

@waruqi
Copy link
Member

waruqi commented Sep 4, 2023

生成的源代码里面是这样的:

html 那个不要去用了,上面说了,走 EXPORT_NAME 你得自定义 html 。。它那个 html ,是 xmake 从 emcc 自动 copy 过去的。不一定完全一致,编译输出已经走了 -o app.js 而不是 -o app.html 了。。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


The generated source code looks like this:

Don’t use the html one. As mentioned above, you have to customize html when you go to EXPORT_NAME. . Its html is automatically copied by xmake from emcc. Not necessarily exactly the same, the compiled output has gone -o app.js instead of -o app.html. .

@da-liii
Copy link
Member Author

da-liii commented Sep 4, 2023

https://github.com/waltoss/qt-wasm-nextjs-example 这个项目可以用来测试生成的wasm是否生效,今天晚点我试试。

因为这个项目已经用cmake构建成功,而且构建产物就在仓库里面。

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


https://github.com/waltoss/qt-wasm-nextjs-example This project can be used to test whether the generated wasm works. I will try it later today.

@da-liii
Copy link
Member Author

da-liii commented Sep 4, 2023

我用xmake构建生成的wasm替换了 https://github.com/waltoss/qt-wasm-nextjs-example 里面的wasm,还是有问题

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


I replaced the wasm in https://github.com/waltoss/qt-wasm-nextjs-example with the wasm generated by xmake build, but there is still a problem

@da-liii
Copy link
Member Author

da-liii commented Sep 4, 2023

然后,我注意到,我生成的wasm只有11m,qt-wasm-nextjs-example里面的wasm有21M

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Then, I noticed that the wasm I generated was only 11M, and the wasm in qt-wasm-nextjs-example was 21M

@waruqi
Copy link
Member

waruqi commented Sep 4, 2023

你可以对下两边的 编译和链接的 flags 差异

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


You can compare the flags difference between compile and link on both sides

@da-liii
Copy link
Member Author

da-liii commented Sep 4, 2023

cmake的编译参数:

[ 50%] Building CXX object CMakeFiles/qt-wasm-component.dir/main.cpp.o
/home/da/.xmake/packages/e/emscripten/3.1.25/79e74f9c8c4c43e8a2361e27d1d19f32/upstream/emscripten/em++ -DQT_CORE_LIB -DQT_GUI_LIB -DQT_NO_DEBUG -DQT_WIDGETS_LIB @CMakeFiles/qt-wasm-component.dir/includes_CXX.rsp -std=gnu++17 -MD -MT CMakeFiles/qt-wasm-component.dir/main.cpp.o -MF CMakeFiles/qt-wasm-component.dir/main.cpp.o.d -o CMakeFiles/qt-wasm-component.dir/main.cpp.o -c /home/da/qt-wasm-nextjs-example/packages/qt-wasm-component/main.cpp
[100%] Linking CXX executable qt-wasm-component.js
/usr/bin/cmake -E cmake_link_script CMakeFiles/qt-wasm-component.dir/link.txt --verbose=1
/home/da/.xmake/packages/e/emscripten/3.1.25/79e74f9c8c4c43e8a2361e27d1d19f32/upstream/emscripten/em++ -s INITIAL_MEMORY=50MB -s EXPORTED_RUNTIME_METHODS=UTF16ToString,stringToUTF16,JSEvents,specialHTMLTargets -s MAX_WEBGL_VERSION=2 -s FETCH=1 -s WASM_BIGINT=1 -s MODULARIZE=1 -s EXPORT_NAME=createQtAppInstance -s DISABLE_EXCEPTION_CATCHING=1 -s ALLOW_MEMORY_GROWTH -sASYNCIFY_IMPORTS=qt_asyncify_suspend_js,qt_asyncify_resume_js -s ERROR_ON_UNDEFINED_SYMBOLS=1 @CMakeFiles/qt-wasm-component.dir/objects1.rsp -o qt-wasm-component.js @CMakeFiles/qt-wasm-component.dir/linklibs.rsp

linklibs.rsp:

 /home/da/6.5.1/wasm_singlethread/lib/objects-Release/QWasmIntegrationPlugin_resources_1/.rcc/qrc_wasmfonts.cpp.o /home/da/6.5.1/wasm_singlethread/lib/objects-Release/QWasmIntegrationPlugin_resources_2/.rcc/qrc_wasmwindow.cpp.o /home/da/6.5.1/wasm_singlethread/lib/objects-Release/Gui_resources_1/.rcc/qrc_qpdf.cpp.o /home/da/6.5.1/wasm_singlethread/lib/objects-Release/Gui_resources_2/.rcc/qrc_gui_shaders.cpp.o /home/da/6.5.1/wasm_singlethread/lib/objects-Release/Widgets_resources_1/.rcc/qrc_qstyle.cpp.o /home/da/6.5.1/wasm_singlethread/lib/objects-Release/Widgets_resources_2/.rcc/qrc_qstyle1.cpp.o /home/da/6.5.1/wasm_singlethread/lib/objects-Release/Widgets_resources_3/.rcc/qrc_qmessagebox.cpp.o /home/da/6.5.1/wasm_singlethread/lib/libQt6Core.a /home/da/6.5.1/wasm_singlethread/./plugins/imageformats/libqgif.a /home/da/6.5.1/wasm_singlethread/./plugins/imageformats/libqicns.a /home/da/6.5.1/wasm_singlethread/./plugins/imageformats/libqico.a /home/da/6.5.1/wasm_singlethread/./plugins/imageformats/libqjpeg.a /home/da/6.5.1/wasm_singlethread/./plugins/iconengines/libqsvgicon.a /home/da/6.5.1/wasm_singlethread/./plugins/imageformats/libqsvg.a /home/da/6.5.1/wasm_singlethread/./plugins/imageformats/libqtga.a /home/da/6.5.1/wasm_singlethread/./plugins/imageformats/libqtiff.a /home/da/6.5.1/wasm_singlethread/./plugins/platforms/libqwasm.a /home/da/6.5.1/wasm_singlethread/./plugins/imageformats/libqwbmp.a /home/da/6.5.1/wasm_singlethread/./plugins/imageformats/libqwebp.a /home/da/6.5.1/wasm_singlethread/lib/libQt6Widgets.a /home/da/6.5.1/wasm_singlethread/lib/libQt6BundledLibjpeg.a /home/da/6.5.1/wasm_singlethread/lib/libQt6Svg.a /home/da/6.5.1/wasm_singlethread/lib/libQt6OpenGL.a /home/da/6.5.1/wasm_singlethread/lib/libQt6Gui.a /home/da/6.5.1/wasm_singlethread/lib/libQt6BundledHarfbuzz.a /home/da/6.5.1/wasm_singlethread/lib/libQt6BundledFreetype.a /home/da/6.5.1/wasm_singlethread/lib/libQt6BundledLibpng.a /home/da/6.5.1/wasm_singlethread/lib/libQt6Core.a /home/da/6.5.1/wasm_singlethread/lib/libQt6BundledZLIB.a /home/da/6.5.1/wasm_singlethread/lib/libQt6BundledPcre2.a -lembind

objects1.rsp

CMakeFiles/qt-wasm-component.dir/main.cpp.o /home/da/6.5.1/wasm_singlethread/plugins/imageformats/objects-Release/QGifPlugin_init/QGifPlugin_init.cpp.o /home/da/6.5.1/wasm_singlethread/plugins/imageformats/objects-Release/QICNSPlugin_init/QICNSPlugin_init.cpp.o /home/da/6.5.1/wasm_singlethread/plugins/imageformats/objects-Release/QICOPlugin_init/QICOPlugin_init.cpp.o /home/da/6.5.1/wasm_singlethread/plugins/imageformats/objects-Release/QJpegPlugin_init/QJpegPlugin_init.cpp.o /home/da/6.5.1/wasm_singlethread/plugins/iconengines/objects-Release/QSvgIconPlugin_init/QSvgIconPlugin_init.cpp.o /home/da/6.5.1/wasm_singlethread/plugins/imageformats/objects-Release/QSvgPlugin_init/QSvgPlugin_init.cpp.o /home/da/6.5.1/wasm_singlethread/plugins/imageformats/objects-Release/QTgaPlugin_init/QTgaPlugin_init.cpp.o /home/da/6.5.1/wasm_singlethread/plugins/imageformats/objects-Release/QTiffPlugin_init/QTiffPlugin_init.cpp.o /home/da/6.5.1/wasm_singlethread/plugins/platforms/objects-Release/QWasmIntegrationPlugin_init/QWasmIntegrationPlugin_init.cpp.o /home/da/6.5.1/wasm_singlethread/plugins/imageformats/objects-Release/QWbmpPlugin_init/QWbmpPlugin_init.cpp.o /home/da/6.5.1/wasm_singlethread/plugins/imageformats/objects-Release/QWebpPlugin_init/QWebpPlugin_init.cpp.o

@da-liii
Copy link
Member Author

da-liii commented Sep 4, 2023

xmake的编译参数:

[ 20%]: cache compiling.release main.cpp
/home/da/.xmake/packages/e/emscripten/3.1.25/79e74f9c8c4c43e8a2361e27d1d19f32/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -I/home/da/qt-wasm-nextjs-example/packages/qt-wasm-component/build/.gens/qt-wasm-component/wasm/wasm32/release/rules/qt/ui -DQT_NO_DEBUG -DQT_DEPRECATED_WARNINGS -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_CORE_LIB -isystem /home/da/6.5.1/wasm_singlethread/include/QtOpenGL -isystem /home/da/6.5.1/wasm_singlethread/include/QtOpenGL/6.5.1 -isystem /home/da/6.5.1/wasm_singlethread/include/QtOpenGL/6.5.1/QtOpenGL -isystem /home/da/6.5.1/wasm_singlethread/include/QtGui -isystem /home/da/6.5.1/wasm_singlethread/include/QtGui/6.5.1 -isystem /home/da/6.5.1/wasm_singlethread/include/QtGui/6.5.1/QtGui -isystem /home/da/6.5.1/wasm_singlethread/include/QtWidgets -isystem /home/da/6.5.1/wasm_singlethread/include/QtWidgets/6.5.1 -isystem /home/da/6.5.1/wasm_singlethread/include/QtWidgets/6.5.1/QtWidgets -isystem /home/da/6.5.1/wasm_singlethread/include/QtCore -isystem /home/da/6.5.1/wasm_singlethread/include/QtCore/6.5.1 -isystem /home/da/6.5.1/wasm_singlethread/include/QtCore/6.5.1/QtCore -isystem /home/da/6.5.1/wasm_singlethread/include -isystem /home/da/6.5.1/wasm_singlethread/mkspecs/wasm-emscripten -DNDEBUG -fPIC -o build/.objs/qt-wasm-component/wasm/wasm32/release/main.cpp.o main.cpp
[ 20%]: cache compiling.release build/.qt/plugin/qt-wasm-component/static_import.cpp
/home/da/.xmake/packages/e/emscripten/3.1.25/79e74f9c8c4c43e8a2361e27d1d19f32/upstream/emscripten/emcc -c -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -I/home/da/qt-wasm-nextjs-example/packages/qt-wasm-component/build/.gens/qt-wasm-component/wasm/wasm32/release/rules/qt/ui -DQT_NO_DEBUG -DQT_DEPRECATED_WARNINGS -DQT_OPENGL_LIB -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_CORE_LIB -isystem /home/da/6.5.1/wasm_singlethread/include/QtOpenGL -isystem /home/da/6.5.1/wasm_singlethread/include/QtOpenGL/6.5.1 -isystem /home/da/6.5.1/wasm_singlethread/include/QtOpenGL/6.5.1/QtOpenGL -isystem /home/da/6.5.1/wasm_singlethread/include/QtGui -isystem /home/da/6.5.1/wasm_singlethread/include/QtGui/6.5.1 -isystem /home/da/6.5.1/wasm_singlethread/include/QtGui/6.5.1/QtGui -isystem /home/da/6.5.1/wasm_singlethread/include/QtWidgets -isystem /home/da/6.5.1/wasm_singlethread/include/QtWidgets/6.5.1 -isystem /home/da/6.5.1/wasm_singlethread/include/QtWidgets/6.5.1/QtWidgets -isystem /home/da/6.5.1/wasm_singlethread/include/QtCore -isystem /home/da/6.5.1/wasm_singlethread/include/QtCore/6.5.1 -isystem /home/da/6.5.1/wasm_singlethread/include/QtCore/6.5.1/QtCore -isystem /home/da/6.5.1/wasm_singlethread/include -isystem /home/da/6.5.1/wasm_singlethread/mkspecs/wasm-emscripten -DNDEBUG -fPIC -o build/.objs/qt-wasm-component/wasm/wasm32/release/build/.qt/plugin/qt-wasm-component/static_import.cpp.o build/.qt/plugin/qt-wasm-component/static_import.cpp
[ 60%]: linking.release qt-wasm-component.js
/home/da/.xmake/packages/e/emscripten/3.1.25/79e74f9c8c4c43e8a2361e27d1d19f32/upstream/emscripten/em++ -o build/wasm/wasm32/release/qt-wasm-component.js build/.objs/qt-wasm-component/wasm/wasm32/release/main.cpp.o build/.objs/qt-wasm-component/wasm/wasm32/release/build/.qt/plugin/qt-wasm-component/static_import.cpp.o /home/da/6.5.1/wasm_singlethread/lib/objects-Release/Gui_resources_1/.rcc/qrc_qpdf.cpp.o /home/da/6.5.1/wasm_singlethread/lib/objects-Release/Gui_resources_2/.rcc/qrc_gui_shaders.cpp.o /home/da/6.5.1/wasm_singlethread/lib/objects-Release/Widgets_resources_1/.rcc/qrc_qstyle.cpp.o /home/da/6.5.1/wasm_singlethread/lib/objects-Release/Widgets_resources_3/.rcc/qrc_qmessagebox.cpp.o /home/da/6.5.1/wasm_singlethread/lib/objects-Release/Widgets_resources_2/.rcc/qrc_qstyle1.cpp.o -L/home/da/6.5.1/wasm_singlethread/plugins/platforms -L/home/da/6.5.1/wasm_singlethread/lib -O3 -lembind -lqwasm -lQt6OpenGL -lQt6Gui -lQt6Widgets -lQt6Core -lQt6BundledLibjpeg -lQt6BundledHarfbuzz -lQt6BundledZLIB -lQt6BundledFreetype -lQt6BundledPcre2 -lQt6BundledLibpng -s WASM=1 -s FETCH=1 -s FULL_ES2=1 -s FULL_ES3=1 -s USE_WEBGL2=1 --bind -s ERROR_ON_UNDEFINED_SYMBOLS=1 -s EXPORTED_RUNTIME_METHODS=[\"UTF16ToString\",\"stringToUTF16\"] -s ALLOW_MEMORY_GROWTH=1 -s MODULARIZE=1 -s EXPORT_NAME=createQtAppInstance

@waruqi
Copy link
Member

waruqi commented Sep 4, 2023

编译flags 差别不大,主要是一些 link flags ,尤其的 -s xxx 的配置差异。。

你可以直接改改

target:add("ldflags", "-s WASM=1", "-s FETCH=1", "-s FULL_ES2=1", "-s FULL_ES3=1", "-s USE_WEBGL2=1", "--bind")

挨个跟 cmake link flags 对齐,然后运行下试试,看看具体哪个 flags 影响了运行

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


There is not much difference in the compilation flags, mainly some link flags, especially the configuration difference of -s xxx. .

You can change it directly

target:add("ldflags", "-s WASM=1", "-s FETCH=1", "-s FULL_ES2=1", "-s FULL_ES3=1", "-s USE_WEBGL2=1", "--bind")

Align with the cmake link flags one by one, and then try to run it to see which flags affect the operation

@da-liii
Copy link
Member Author

da-liii commented Sep 7, 2023

链接参数之外,还有一些两个 .o 文件:

/home/da/6.5.2/wasm_singlethread/lib/objects-Release/QWasmIntegrationPlugin_resources_1/.rcc/qrc_wasmfonts.cpp.o
/home/da/6.5.2/wasm_singlethread/lib/objects-Release/QWasmIntegrationPlugin_resources_2/.rcc/qrc_wasmwindow.cpp.o

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


In addition to link parameters, there are two .o files:

/home/da/6.5.2/wasm_singlethread/lib/objects-Release/QWasmIntegrationPlugin_resources_1/.rcc/qrc_wasmfonts.cpp.o
/home/da/6.5.2/wasm_singlethread/lib/objects-Release/QWasmIntegrationPlugin_resources_2/.rcc/qrc_wasmwindow.cpp.o

@da-liii
Copy link
Member Author

da-liii commented Sep 7, 2023

调整了链接参数,并添加了上面的 .o 文件:#4175
在Qt 5和Qt 6都验证了

@waruqi
Copy link
Member

waruqi commented Sep 8, 2023

调整了链接参数,并添加了上面的 .o 文件:#4175 在Qt 5和Qt 6都验证了

看 patch ,没看到 哪里有加 QWasmIntegrationPlugin 的 .o 么,还是我之前对 .o 的处理修复。。

另外, 可以 add_frameworks("QWasmIntegrationPlugin") 把对应这两 .o 加进来

@da-liii
Copy link
Member Author

da-liii commented Sep 8, 2023

没有自动加 QWasmIntegrationPlugin,你那个代码里面,强制要求 Qt 开头

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


Did not automatically add QWasmIntegrationPlugin, in your code, it is mandatory to start with Qt

@waruqi
Copy link
Member

waruqi commented Sep 8, 2023

我 merge 了,如果有其他需要改进的 可以再提 pr

@Issues-translate-bot
Copy link

Bot detected the issue body's language is not English, translate it automatically.


I have merged, if there are other improvements that need to be improved, you can submit a pr again

@waruqi waruqi closed this as completed Sep 8, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants