Hi ![]()
I’ve been playing around a bit with webassembly - starting with a sokol-zig-imgui-sample which provides a template with sokol and imgui (which uses emscripten).
I’ve managed to get it working using --js-library which involves passing int a javascript file which defines the extern function.
What I’d like to do instead is to do away with the js file and use em_js in emscripten.
Why?
- Curiosity - I’d like to understand if and how I can get it working
- I’d rather have a c file in the project than a js file
However, I’ve run into a linker error that I don’t seem to be able to resolve.
error: undefined symbol: jsLog (referenced by root reference (e.g. compiled C/C++ code))
warning: To disable errors for undefined symbols use `-sERROR_ON_UNDEFINED_SYMBOLS=0`
warning: _jsLog may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
emcc: error: '/shri-tmp/zig/p/N-V-__8AAEWFDwBdd7oE1EcCE3lK2y01-2ourXGKhpZeaZxQ/node/22.16.0_64bit/bin/node /shri-tmp/zig/p/N-V-__8AAEWFDwBdd7oE1EcCE3lK2y01-2ourXGKhpZeaZxQ/upstream/emscripten/tools/compiler.mjs -' failed (returned 1)
error: stderr:
error: undefined symbol: jsLog (referenced by root reference (e.g. compiled C/C++ code))
warning: To disable errors for undefined symbols use `-sERROR_ON_UNDEFINED_SYMBOLS=0`
warning: _jsLog may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors
emcc: error: '/shri-tmp/zig/p/N-V-__8AAEWFDwBdd7oE1EcCE3lK2y01-2ourXGKhpZeaZxQ/node/22.16.0_64bit/bin/node /shri-tmp/zig/p/N-V-__8AAEWFDwBdd7oE1EcCE3lK2y01-2ourXGKhpZeaZxQ/upstream/emscripten/tools/compiler.mjs -' failed (returned 1)
error: the following command exited with error code 1:
/home/shri/.cache/zig/p/N-V-__8AAEWFDwBdd7oE1EcCE3lK2y01-2ourXGKhpZeaZxQ/upstream/emscripten/emcc -Og -sSAFE_HEAP=1 -sSTACK_OVERFLOW_CHECK=1 -sUSE_WEBGL2=1 -sNO_FILESYSTEM=1 "-sMALLOC='emmalloc'" --shell-file=/home/shri/.cache/zig/p/sokol-0.1.0-pb1HK1HTLQAsjVm5gHGpGI85Rwhwvu2KgCOTH-ZJ9sCS/src/sokol/web/shell.html ./.zig-cache/o/da30d3b095117c29efb96f800e23b36d/libshine.a ./.zig-cache/o/da30d3b095117c29efb96f800e23b36d/libshine.a ./.zig-cache/o/a3332d7b349381aee3e9ec9a0f037be3/libsokol_clib.a ./.zig-cache/o/7a172070ee71a28bcfb28c07fbe28cb7/libcimgui_clib.a -o /shri-tmp/triangle/games/shine/.zig-cache/o/a1cacaef35724976a8454515bb2f39d8/shine.html
Some research led me to this google groups discussion which suggests an issue with how the function is exported (I struggled with really understanding it). I am, however, not clear on whether it really applies to my situation or how to apply the suggestions.
I have forked the template project and added the smallest change to reproduce the problem into a forked repo
can someone here can point me in the right direction?
Thank you