This is the mail archive of the gcc@gcc.gnu.org mailing list for the GCC project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Re: How can I make ELF library in C++ ?


If you'd like to accept a compromised scheme, you could build your ELF shared library in C++ because libtool or ranlib just merges the *.o and *.a. The point is that in C++ symbols are mangled by compiler. So you can't dlopen C++ functions as what you do in C. You must rewrite your C++ program with the declaration: extern "C" in your headers for C++. Then the binary of C++ code is of C declaration.

It seems weird.

Best regards,

Yu Xuanwei

----- Original Message ----- 
From: Erik Mouw <J.A.K.Mouw@ITS.TUDelft.NL>
To: Ghost in the shell <dodeskaden@free.fr>
Cc: <gcc@gcc.gnu.org>
Sent: Monday, February 26, 2001 8:56 PM
Subject: Re: How can I make ELF library in C++ ?


> On Sun, Feb 25, 2001 at 03:30:42PM +0100, Ghost in the shell wrote:
> > I've seen that there were some troubles when I try to use dlsym in a C++
> > program because the ELF format library compiled by g++ doesn't look like
> > the ELF's one compiled by a c compiler.
> 
> Loading C++ modules in C programs is non trivial because C++ code
> usually needs some initialisation.
> 
> > I'm asking How to make and use ELF library in c++ ?
> 
> Use libtool to make library files, see http://www.gnu.org/software/libtool/
> (or "apt-get install libtool" on your Debian system).
> 
> To use them, have a look at the GLib's portable method for loading
> "plug-ins":
> 
>   http://developer.gnome.org/doc/API/glib/glib-dynamic-loading-of-modules.html
> 
> 
> 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/
> 

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]