Skip to Main Content

DevOps, CI/CD and Automation

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Catching exceptions in extern C dlsym libs?

807575Jul 21 2004 — edited Jul 21 2004
I'm writing a C++ (ish) application that uses dynamic libraries loaded using dlopen and functions called by dlsym. Because of the name mangling this involves, all of the functions are prototyped inside an extern C block.

These library functions are passed object references, and call their methods, which are defined back in the main application. Unfortunately, the code inside the library is unable to catch any exceptions thrown. I presume this has something to do with namespaces or some other kind of name mangling, since other methods in the main application that call these methods are able to catch the exceptions.

Is there an obvious way around this... other than rewriting all of my C++ code so that it doesn't throw exceptions for errors?

I'm compiling both main app and libraries using "g++ -Wall -O -fPIC" - I realise this isn't a Sun Studio app, but on comp.lang.c++.moderated they said they'd seen the same problem with Sun's compiler, and that this behaviour seems to be more bound to the platform (i.e. Solaris) rather than the language.

Many thanks for any help you can provide....

Paul
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 18 2004
Added on Jul 21 2004
1 comment
389 views