This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: problems catching std::runtime_error in a .so built with -fPIC
- From: Ian Lance Taylor <iant at google dot com>
- To: Hasan Mahmood <hasan dot mahm at gmail dot com>
- Cc: gcc-help at gcc dot gnu dot org
- Date: Wed, 22 Apr 2009 14:19:11 -0700
- Subject: Re: problems catching std::runtime_error in a .so built with -fPIC
- References: <c12488d10904220904w766ae1cdt657e0a1a87056d4f@mail.gmail.com>
Hasan Mahmood <hasan.mahm@gmail.com> writes:
> I am having a problem trying to catch std::runtime_error (thrown from
> libstdc++) in a .so I built with -fPIC. If I build without -fPIC, I
> can catch the exception. Here is the code in the .so:
What operating system are you using?
What version of gcc are you using?
What happens when the program does not work as you expect?
In general you can only catch an exception thrown by a shared library if
you are using a shared libgcc or if you are using a linker which
supports the --eh-frame-hdr option. So first confirm that one or the
other is the case. Use ldd to see whether you are linking against a
shared libgcc (named libgccc_s). Use -v when linking to see whether gcc
pases --eh-frame-hdr to the linker.
Ian