Try either add '__attribute__((used))' or defining the constant as 'static inline'.
On Thu, 26 Dec 2019 at 20:32, キャロウ マーク <[email protected]> wrote: > I am trying to use embind to provide a JS API to some c/c++ code. The > underlying code is c and I have a small wrapper to give it a proper c++ > api. My file ktx_wrappers.cpp contains this c++ wrapper and the > EMSCRIPTEN_BINDINGS. Due to the build system I am using, this is first > compiled to a .o then in a second step linked with the underlying library, > also previously compiled, to produce the .js file. > > The wrapper class contains (simplified for illustration) > > namespace ktx_wrappers > { > class texture > { > public: > ... > static const uint32_t KTX_FOO = 1; > ... > } > } > > EMSCRIPTEN_BINDINGS contains > > EMSCRIPTEN_BINDINGS(ktx_wrappers) > { > class_<ktx_wrappers::texture>("ktxTexture") > .class_property("KTX_FOO", &ktx_wrappers::texture::KTX_FOO) > … > ; > } > > This compiles fine but on link wasm-ld reports "undefined symbol: > ktx_wrappers::texture::KTX_FOO”. llvm-nm on ktx_wrappers.o indeed shows > that this symbol is undefined. > > I am specifying —bind on both the compile & link commands. > > How to I prevent the compiler removing this symbol? Is it being removed > because none of the class texture methods reference this static class > constant? > > Regards > > -Mark > > > > > -- > You received this message because you are subscribed to the Google Groups > "emscripten-discuss" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To view this discussion on the web visit > https://groups.google.com/d/msgid/emscripten-discuss/E89A8902-A981-43A2-8C04-6D9CAA99AF10%40callow.im > . > -- You received this message because you are subscribed to the Google Groups "emscripten-discuss" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/CA%2B_KjGacz9Fee0mONw-bRpsfBqsxX8r8Hn5%3D7vbXO7u7Zdh6EQ%40mail.gmail.com.
