Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.c++ > #11189

Re: Anything new on run-time libraries loading?

From Edek <edek.pienkowski@gmail.com>
Newsgroups comp.lang.c++
Subject Re: Anything new on run-time libraries loading?
Date 2011-11-02 10:01 +0100
Organization ATMAN - ATM S.A.
Message-ID <j8r0rb$mqa$1@node2.news.atman.pl> (permalink)
References <2u8yuf1f8xnx$.dlg@localhost.localdomain> <Xns9F90EFDA58424myfirstnameosapriee@216.196.109.131>

Show all headers | View raw


On 11/01/2011 10:34 PM, Paavo Helde wrote:
> "Waldek M."<wm@localhost.localdomain>  wrote in
> news:2u8yuf1f8xnx$.dlg@localhost.localdomain:
>
>> Hello,
>>
>> The standard way for loading libraries on runtime (in this case, for
>> Linux/Unix systems) is dlsym/dlopen&  friends.
>> The catch is, libraries written with C++ need to have some
>> kind of "C" interface (hence not mangled) that would allow access to
>> C++ objects, at least supporting creation and destruction, like here:
>> http://tldp.org/HOWTO/C++-dlopen/thesolution.html
>>
>> And my question: does the new C++ standard address this issue somehow?
>> Or, is there any more comfortable (still standard compliant) way to
>> achieve the same goal?
>
> Adding a couple of extern "C" is as comfortable as you can get. Note that
> the function marked extern "C" can be otherwise fully C++ in both the
> definition and signature. There might be some complications, e.g.
> throwing exceptions across the extern "C" border is not guaranteed to
> work IIRC.

That is in the scope of factory methods, all other calls can be C++
(see the triangle example in the mentioned FAQ)

>
> If you want to pass C++ objects, both libraries must be binary compatible
> anyway, so in principle nothing prevents you sneaking out the mangled
> name by the nm tool and using that in your dlsym() calls. However, this
> is much more fragile than using extern "C" (there were times when gcc
> changed its name mangling rules about every minor release, for example).

Why would you use nm? Why not make an extern C factory method returning
an object with virtual methods you can call (same example)?

Edek

Back to comp.lang.c++ | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread


Thread

Anything new on run-time libraries loading? "Waldek M." <wm@localhost.localdomain> - 2011-10-31 18:54 +0100
  Re: Anything new on run-time libraries loading? Goran <goran.pusic@gmail.com> - 2011-10-31 12:34 -0700
    Re: Anything new on run-time libraries loading? legalize+jeeves@mail.xmission.com (Richard) - 2011-11-01 05:28 +0000
      Re: Anything new on run-time libraries loading? Ian Collins <ian-news@hotmail.com> - 2011-11-01 19:49 +1300
      Re: Anything new on run-time libraries loading? Dombo <dombo@disposable.invalid> - 2011-11-01 20:30 +0100
        Re: Anything new on run-time libraries loading? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-11-02 06:08 +0000
          Re: Anything new on run-time libraries loading? Edek <edek.pienkowski@gmail.com> - 2011-11-02 10:03 +0100
            Re: Anything new on run-time libraries loading? Dombo <dombo@disposable.invalid> - 2011-11-02 19:38 +0100
            Re: Anything new on run-time libraries loading? Jorgen Grahn <grahn+nntp@snipabacken.se> - 2011-11-03 18:26 +0000
              Re: Anything new on run-time libraries loading? Edek <edek.pienkowski@gmail.com> - 2011-11-03 20:07 +0100
    Re: Anything new on run-time libraries loading? "Waldek M." <wm@localhost.localdomain> - 2011-11-01 08:28 +0100
    Re: Anything new on run-time libraries loading? Edek <edek.pienkowski@gmail.com> - 2011-11-01 11:28 +0100
  Re: Anything new on run-time libraries loading? Paavo Helde <myfirstname@osa.pri.ee> - 2011-11-01 16:34 -0500
    Re: Anything new on run-time libraries loading? Edek <edek.pienkowski@gmail.com> - 2011-11-02 10:01 +0100
      Re: Anything new on run-time libraries loading? Paavo Helde <myfirstname@osa.pri.ee> - 2011-11-02 17:03 -0500
        Re: Anything new on run-time libraries loading? Edek <edek.pienkowski@gmail.com> - 2011-11-03 20:40 +0100
        Re: Anything new on run-time libraries loading? "Waldek M." <wm@localhost.localdomain> - 2011-11-03 21:06 +0100

csiph-web