Using dlsym in c++ without extern “C”

前端 未结 3 2039
旧巷少年郎
旧巷少年郎 2021-01-14 18:11

I have a system in which I give the user a function prototype and the user has to implement it. Now, I compile this file using g++ and load it dynamically using dlopen and d

3条回答
  •  太阳男子
    2021-01-14 18:51

    Since you are using C++, why don't you export only one (or two) functions that will simply return a pointer to some kind of pure virtual class, say IMyModule? The one (or two) exported extern "C" functions would be something similar to extern "C" IMyModule * create_instance_IMyModule(); (and extern "C" void delete_instance_IMyModule(IMyModule const *);).

提交回复
热议问题