dynamic library loading and c++ exception
H . J . Lu
hjl@valinux.com
Tue Jan 23 22:55:00 GMT 2001
On Tue, Jan 23, 2001 at 02:44:52PM +0100, Vianney Lecroart wrote:
> Hello All.
>
> I'm using RedHat7.0 and gcc 2.96.
> I wrote a tiny C++ program that simply loads a (C++) dynamic library,
> calls a function and unloads it. The problem is that if an exception
> is thrown inside the library (and caught there) the program aborts.
> The output is:
>
> [alfa:~/tmp] app
> Abort
>
> In particular, if I comment out the "throw" line in the lib, everything
> works well. Does somebody knows what's going on? Since I have no idea
> about it, maybe I'm sending this to the wrong list--excuse me for that.
>
> Please, c.c. the answer to me because I'm not a list member.
>
> Code for both files follows, app.cpp is the application and lib.cpp is
> the dynamic library.
>
It works for me under RedHat 7.0. I guess you didn't build the shared
library right. I used
# gcc -shared -o liblib.so -fPIC lib.cpp
H.J.
More information about the Gcc
mailing list