Need help resolving undefined symbols at compile time
-
I am brand new to Web Assembly. I have a small Qt Widgets app that builds and runs fine on my KDE Neon (Ubuntu 20.4) Linux desktop using Qt Creator with Qt 6.3.0 and gcc 9.4.0. When I would start Qt Creator, it would put a note along the bottom saying I did not have a Web Assembly kit configured. I clicked the setup button. It directed me to a page for installing emsdk. I cloned that repo and ran through the few commands to install it and put it in my PATH. Qt Creator then found the emsdk and configured the kit. I tried building my project, which uses CMake. I get a few undefined symbol errors (below) before em++ stops. I've read about building Qt from source for cross compiling. Is that something I need to do even though I included Web Assembly during the Qt installation? Any help would be much appreciated!
error: undefined symbol: _ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv (referenced by top-level compiled C/C++ code)
warning: Link with-sLLD_REPORT_UNDEFINED
to get more information on undefined symbols
warning: To disable errors for undefined symbols use-sERROR_ON_UNDEFINED_SYMBOLS=0
warning: __ZNKSt3__220__vector_base_commonILb1EE20__throw_length_errorEv may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZNKSt3__221__basic_string_commonILb1EE20__throw_length_errorEv (referenced by top-level compiled C/C++ code)
warning: __ZNKSt3__221__basic_string_commonILb1EE20__throw_length_errorEv may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
error: undefined symbol: _ZNKSt3__221__basic_string_commonILb1EE20__throw_out_of_rangeEv (referenced by top-level compiled C/C++ code)
warning: __ZNKSt3__221__basic_string_commonILb1EE20__throw_out_of_rangeEv may need to be added to EXPORTED_FUNCTIONS if it arrives from a system library
Error: Aborting compilation due to previous errors -
I posted this reply in another thread I had started to ask about example source. But, I figured I would post it here, since this is the thread it belongs in.
I can build and run c++ test apps with the emsdk and load them in a browser without any issue. I did have to add a flag to the emcc command line to enable exceptions. But, I later went into the emsdk's settings.js and changed DISABLE_EXCEPTION_CATCHING to false. Now I can build with emcc and run in the browser without specifying the option on the command line. Unfortunately, none of this has helped me when building within Qt Creator. I still get the same unresolved functions. The odd part is that, despite me modifying settings.js, I still see that the emcc command that Qt is executing has DISABLE_EXCEPTION_CATCHING=1. I don't see where this is being set in the project or kit settings. I've tried adding "-s DISABLE_EXCEPTION_CATCHING=0" in my CMakeLists.txt via add_compile_options() and add_link_options(). It still doesn't change it.
Does anyone know if that is what is causing the errors?
Does anyone know how I tell Qt to stop setting DISABLE_EXCEPTION_CATCHING to 1?
-
You have to make changes in makefile -sERROR_ON_UNDEFINED_SYMBOLS=0.
-
You have to make changes in makefile -sERROR_ON_UNDEFINED_SYMBOLS=0.
@SandeepKg1 It is a bad idea to edit generated makefiles. And disabling the errors instead of solving the actual issue is also a bad idea.
-
For Qt 6.3.0 you need Emscripten 3.0.0. Is that what you have installed?
Those errors look like something that happens when a mis-match of Emscripten versions are used, where Qt uses one version and a developer uses a different one.