This is the mail archive of the
gcc-help@gcc.gnu.org
mailing list for the GCC project.
Re: problems with a .so using dlsym()
- From: Mihnea Balta <dark_lkml at mymail dot ro>
- To: Miguel Angel de Vega <mvega at sgo dot es>, gcc-help at gcc dot gnu dot org
- Date: Mon, 21 Jul 2003 15:08:32 +0300
- Subject: Re: problems with a .so using dlsym()
- References: <200307211356.04406.mvega@sgo.es>
Those are C++ mangled names. In order to obtain them through dlopen() with
their sourcecode names, you have to declare them as extern "C", i.e. :
extern "C"{
void copyFromTemplate();
};
[...]
void copyFromTemplate(){
[...]
}
This way the name won't be decorated in C++ manner (but you can't use
overloading and other stuff either).
If you want to export classes from your plugin, it's a bit more complicated,
since you need to use factories.
On Monday 21 July 2003 14:56, Miguel Angel de Vega wrote:
> Hi all,
>
> I have a external plugin (.so) from my main program, but when I use dlsym()
> function to take the funcions of the .so, with some of then don't work, I
> edit the .so and saw that the functions that don't work with the dlsym call
> have some barbage in the function names (or strange identifiers, i don't
> know), for example:
>
> if I have this function:
> copyFromTemplate();
> in the .so appers like:
> _Z9copyFromTemplatePv
>
> because this i think that the dlsym() call fails... someone can help me?
> thanks all ways :)