How to catch exception thrown from library in GCC C++?

后端 未结 2 1086
执笔经年
执笔经年 2021-01-01 06:00

When i use dlopen to dynamically load a library it seems i can not catch exceptions thrown by that library. As i understand it it\'s because dlopen is a C function.

相关标签:
2条回答
  • 2021-01-01 06:49

    You need to specify RTLD_GLOBAL flag to dlopen. This will allow correct weak symbol binding, so each typeinfo symbol for exception object will point at the same place, which is needed by exception processing ABI code.

    0 讨论(0)
  • 2021-01-01 06:57

    This depends on the version of GCC you are using.
    First of all, make sure you compile everything with "-fPIC" and link with the "-rdynamic" flag.
    RTLD_NOW flag is still needed.

    0 讨论(0)
提交回复
热议问题