This is the mail archive of the
gcc@gcc.gnu.org
mailing list for the GCC project.
Re: How can I make ELF library in C++ ?
On Tue, Feb 27, 2001 at 06:02:03PM +0100, Ghost in the shell wrote:
> I use libtool and glib's support but:
>
> I can't use C++ shared library because it seems that the functions symbols
> name in my src ***.cpp have a longer name in the lib***.so. For example:
>
> in src in ELF library
> hello becomes hello__Fv
>
> That happens every time and I need to do g_module_open(..,"hello__Fv",..);
> if I want to load it.
Welcome to C++ name mangling :)
> That isn't a really good way, so ... (and when I use classes, it's going
> worst)
>
> I'd like that C++ loves 'plug-ins' in the C way. ( in C, it so simple..)
Make all functions static, except for the inferface functions, which
should be declared as extern "C". In that case the names won't get
mangled.
> PS: Why should I use glib instead of <dlfnc> ?
Because in that way you can do it in a portable way. Your code compiles
and runs immediately on Solaris, HP/UX, AIX, IRIX, True64 Unix, *BSD,
etc. You don't have to change a single line in your code, glib takes
care of the gory details.
Erik
--
J.A.K. (Erik) Mouw, Information and Communication Theory Group, Department
of Electrical Engineering, Faculty of Information Technology and Systems,
Delft University of Technology, PO BOX 5031, 2600 GA Delft, The Netherlands
Phone: +31-15-2783635 Fax: +31-15-2781843 Email: J.A.K.Mouw@its.tudelft.nl
WWW: http://www-ict.its.tudelft.nl/~erik/