Emscripten: Error: "undefined symbol: _embind_register_function" when compiling with --bind using premake5

Created on 4 Sep 2019  路  2Comments  路  Source: emscripten-core/emscripten

I generate makefiles with premake5 and forward --bind (see premake5.lua in repo link), but i get the following when running emmake make:

error: undefined symbol: _embind_register_function
warning: To disable errors for undefined symbols use `-s ERROR_ON_UNDEFINED_SYMBOLS=0`
Error: Aborting compilation due to previous errors
shared:ERROR: 'node /home/veetaha/apps/emsdk/upstream/emscripten/src/compiler.js /tmp/tmp1lTxqV.txt /home/veetaha/apps/emsdk/upstream/emscripten/src/library_pthread_stub.js' failed (1)

I may be doing something wrong but it is clearly seen that the flag --bind is forwarded to emcc if you inspect Makefike generated by premake5 gmake2, but still the linking fails, even adding -s ERROR_ON_UNDEFINED_SYMBOLS=0 and -s WARN_ON_UNDEFINED_SYMBOLS=0 doesn't remove the error.

Here is the link to the repo with the minimum bug representation.
If you don't want to clone the repo and run makefiles generation command, here is the link to the branch with generated makefiles

Most helpful comment

@kripken @jgravelle-google Sorry for bothering you, but I figured out what was wrong.

It's just I failed to find it in the documentation, but --bind flag is supposed to be passed during the final linking of the program. Moreover I was even mistakenly thinking that make was invoking em++ only once without doing separate step to generate .o files (yeah, very unfortunate).
But what was effectively executing is the following

em++ -o emproj.o index.cpp --bind
em++ -o emproj.js emproj.o

So here is the fix, just add --bind to premake5.lua linkoptions instead of buildoptions:

linkoptions { "--bind" }

All 2 comments

@kripken @jgravelle-google Sorry for bothering you, but I figured out what was wrong.

It's just I failed to find it in the documentation, but --bind flag is supposed to be passed during the final linking of the program. Moreover I was even mistakenly thinking that make was invoking em++ only once without doing separate step to generate .o files (yeah, very unfortunate).
But what was effectively executing is the following

em++ -o emproj.o index.cpp --bind
em++ -o emproj.js emproj.o

So here is the fix, just add --bind to premake5.lua linkoptions instead of buildoptions:

linkoptions { "--bind" }

Great, glad you figured this out @Veetaha! Sounds like we can close this.

Was this page helpful?
0 / 5 - 0 ratings