[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: dlsym() and C++



Quoting Dennis Payne (payned@rpi.edu):

> It's not that it doesn't work under C++.  C++ does name mangling to allow
> for multiple functions with the same name.  For example using nm on
> libcore.so without the extern "C" code gives the following:
> 
> 000004b4 T ugga7__Fi
> 000004e4 T ugga7__Fii
> 00000498 T ugga__Fv
> 
> If you tried dlsym on ugga__Fv it should work.  However since there isn't
> a specific name mangling standard every compiler can implement it
> differently.  To avoid dealing with this most people make the function
> extern "C" which stops the name mangling.

DOH! That's what happen when you do not bother to verify such thing in your
test program - I does fascinate me that I could overlook such _STUPID_
mistake.
It doesn't solve my real problem with dynamic linking - I guess I'll just
have to keep on playing around with my coredumper prog until it actually
does provoke the dynamic linker!

> BTW it would be best to check if symbol is NULL before calling it
> although maybe that was just for this sample code.

I do check that in my ClanLib code. I'll return with a new version of
coredumper when/if I actually does find the bug in the dynamic linker...

--
Magnus Norddahl
ClanSoft