Solved WebAssembly undefined symbol: emscripten_fetch
-
Hi. I am try build me project for web with cmake build system.
But i have a link error.error: undefined symbol: emscripten_fetch warning: Link with `-s LLD_REPORT_UNDEFINED` to get more information on undefined symbols warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0` error: undefined symbol: emscripten_fetch_attr_init error: undefined symbol: emscripten_fetch_close error: undefined symbol: emscripten_fetch_get_response_headers error: undefined symbol: emscripten_fetch_get_response_headers_length Error: Aborting compilation due to previous errors shared:ERROR: '/media/E/builds/emsdk/node/12.9.1_64bit/bin/node /media/E/builds/emsdk/upstream/emscripten/src/compiler.js /tmp/tmpmlllt5bk.txt' failed (1) make[2]: *** [Site/CMakeFiles/Site.dir/build.make:410: ../Site/build/Release/Site.js] Ошибка 1 make[1]: *** [CMakeFiles/Makefile2:245: Site/CMakeFiles/Site.dir/all] Ошибка 2 make: *** [Makefile:104: all] Ошибка 2
Qt version: 5.15.0
em++ version : 1.39.8my custom link flags :
add_link_options("--bind")
my cmake command :
cmake -DCMAKE_TOOLCHAIN_FILE=/media/E/builds/emsdk/upstream/emscripten/cmake/Modules/Platform/Emscripten.cmake -DCMAKE_PREFIX_PATH=/home/andrei/Qt/5.15.0/wasm_32 -DQt5_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5 -DQt5Core_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5Core -DQt5Widgets_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5Widgets -DQt5Gui_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5Gui -DQt5Quick_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5Quick -DQt5QmlModels_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5QmlModels -DQt5Qml_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5Qml -DQt5Network_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5Network -DQt5Svg_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5Svg -DQt5Zlib_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5Zlib -DQt5VirtualKeyboard_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5VirtualKeyboard -DQt5EventDispatcherSupport_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5EventDispatcherSupport -DQt5FontDatabaseSupport_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5FontDatabaseSupport -DQt5LinguistTools_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5LinguistTools -DQt5ThemeSupport_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5ThemeSupport -DQt5WebSockets_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5WebSockets -DQt5EglSupport_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5EglSupport -DQt5QuickControls2_DIR=/home/andrei/Qt/5.15.0/wasm_32/lib/cmake/Qt5QuickControls2
what could be the problem and how to solve it?
-
i am found solution.
I needed to link the project with the following flags:
-s FETCH=1 --bind
in order to add these options to the cmake assembly, add the following line to the main CMakeList.txt:
add_link_options("SHELL:-s FETCH=1") add_link_options("--bind")
I also looked at the output of qmake. and I think I need to add some more build flags.
add_link_options("SHELL:-s FETCH=1") add_link_options("SHELL:-s WASM=1") add_link_options("SHELL:-s FULL_ES2=1") add_link_options("SHELL:-s FULL_ES3=1") add_link_options("SHELL:-s USE_WEBGL2=1") add_link_options("SHELL:-s EXIT_RUNTIME=1") add_link_options("SHELL:-s ERROR_ON_UNDEFINED_SYMBOLS=1") add_link_options("SHELL:-s EXTRA_EXPORTED_RUNTIME_METHODS=[\"UTF16ToString\",\"stringToUTF16\"]") add_link_options("--bind")
-
i am found solution.
I needed to link the project with the following flags:
-s FETCH=1 --bind
in order to add these options to the cmake assembly, add the following line to the main CMakeList.txt:
add_link_options("SHELL:-s FETCH=1") add_link_options("--bind")
I also looked at the output of qmake. and I think I need to add some more build flags.
add_link_options("SHELL:-s FETCH=1") add_link_options("SHELL:-s WASM=1") add_link_options("SHELL:-s FULL_ES2=1") add_link_options("SHELL:-s FULL_ES3=1") add_link_options("SHELL:-s USE_WEBGL2=1") add_link_options("SHELL:-s EXIT_RUNTIME=1") add_link_options("SHELL:-s ERROR_ON_UNDEFINED_SYMBOLS=1") add_link_options("SHELL:-s EXTRA_EXPORTED_RUNTIME_METHODS=[\"UTF16ToString\",\"stringToUTF16\"]") add_link_options("--bind")