I was trying to use dynamic linking using dlopen with emscripten compiler version 1.38.28 and encountered the following problem:
1. When I try to use vector in the SIDE_MODULE, it can't seem to find the new and delete operators in the Module variable.
2. The command I use to build main and side module are:
em++ doubler.cpp -o doubler.wasm -s SIDE_MODULE=1 -O3 -s "EXPORTED_FUNCTIONS=['_doubler']"EMCC_FORCE_STDLIBS=1 em++ main.cpp -O3 -s WASM=1 -s MAIN_MODULE=2 -o dynlink.js -s "EXPORTED_FUNCTIONS=['_main', '_clock', '_tripler', '_printf', '_puts']" -s "DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=['clock']" -s FORCE_FILESYSTEM=1 --pre-js prejs.js
--
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 emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/5f2ad4c5-fc8e-45a3-afab-e340f91f09f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
This is probably because of MAIN_MODULE=2, which means you need to carefully pick what is kept alive for the other modules. Does this work with =1? If so then that's the issue. The test suite has a bunch of examples for mode 2, that might help.
On Wed, May 29, 2019 at 3:40 AM Tapan Anand <anandtap...@gmail.com> wrote:
Hi,I was trying to use dynamic linking using dlopen with emscripten compiler version 1.38.28 and encountered the following problem:1. When I try to use vector in the SIDE_MODULE, it can't seem to find the new and delete operators in the Module variable.2. The command I use to build main and side module are:
em++ doubler.cpp -o doubler.wasm -s SIDE_MODULE=1 -O3 -s "EXPORTED_FUNCTIONS=['_doubler']"EMCC_FORCE_STDLIBS=1 em++ main.cpp -O3 -s WASM=1 -s MAIN_MODULE=2 -o dynlink.js -s "EXPORTED_FUNCTIONS=['_main', '_clock', '_tripler', '_printf', '_puts']" -s "DEFAULT_LIBRARY_FUNCS_TO_INCLUDE=['clock']" -s FORCE_FILESYSTEM=1 --pre-js prejs.jsThe prejs file here is there to use FS.createLazyFile to cause lazy loading of the side module.If I change the exported function list in main_module to `['_main', '_clock', '_tripler', '__Znwm', '__ZdlPv', '_printf', '_puts']` It starts to work. Notice that I had to add the mangled symbols of new and delete operator to export list.Also, once I did this, I didn't get any missing symbols related to the vector class itself.So, I have two questions:1. Do we have to export C++ runtime functions like new, delete, or even c runtime methods like printf, puts for code to work? Is that expected?2. Since there were no errors for vector related symbols, does that mean that vector is linked with the side_module? If I also use vector in main module, will there be effectively two copies of vector? In both side and main module?Thanks in advance!--
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 emscripten-discuss+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/5f2ad4c5-fc8e-45a3-afab-e340f91f09f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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 emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/058436c9-50d5-4a13-a499-cbca19214066%40googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/5f2ad4c5-fc8e-45a3-afab-e340f91f09f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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 emscripten-discuss+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/5f2ad4c5-fc8e-45a3-afab-e340f91f09f5%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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 emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/058436c9-50d5-4a13-a499-cbca19214066%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
--
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 emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/f5c8beed-0aee-4a0f-8748-17321afb48dd%40googlegroups.com.
>>>>> To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.
>>>>> To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/5f2ad4c5-fc8e-45a3-afab-e340f91f09f5%40googlegroups.com.
>>>>> For more options, visit https://groups.google.com/d/optout.
>>>
>>> --
>>> 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 emscripten-discuss+unsub...@googlegroups.com.
>>> To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/058436c9-50d5-4a13-a499-cbca19214066%40googlegroups.com.
>>> For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 emscripten-discuss+unsub...@googlegroups.com.
>> >>>>> To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-discuss+unsub...@googlegroups.com.
>> >>>>> To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/5f2ad4c5-fc8e-45a3-afab-e340f91f09f5%40googlegroups.com.
>> >>>>> For more options, visit https://groups.google.com/d/optout.
>> >>>
>> >>> --
>> >>> 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 emscripten-discuss+unsub...@googlegroups.com.
>> >>> To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/058436c9-50d5-4a13-a499-cbca19214066%40googlegroups.com.
>> >>> For more options, visit https://groups.google.com/d/optout.
>> >
>> > --
>> > 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 emscripten-discuss+unsub...@googlegroups.com.
>> > To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/f5c8beed-0aee-4a0f-8748-17321afb48dd%40googlegroups.com.
>> > For more options, visit https://groups.google.com/d/optout.
>
> --
> 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 emscripten-discuss+unsub...@googlegroups.com.
To unsubscribe from this group and stop receiving emails from it, send an email to emscripten-disc...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/emscripten-discuss/02d6fbff-1de3-45d9-b119-a04231064638%40googlegroups.com.