Re: static class members, shared libs and other vegetables



"Maor Avni" <maor.avni@xxxxxxxxx> writes:

I'm trying to create a quick-and-dirty solution to a problem one of
our customer requires: one of the libs in our product needs to be
instantiated two times. The problem is that it contains many static
members.
....
Our first solution was to compile all libraries to a second set of
libraries, and load the two sets separately. This solution worked on
Windows, and we successful created two instances of every static
member in the system.

The solution doesn't work on Linux, as static members for some reason
are shared across the libraries, although the libraries are loaded
dynamically at the start of the program.

This is *expected*.

Win32 uses a "DLL is a self-contained entity; nothing should change
its behaviour once it has been built" model.

Most UNIXes use a "linking against DSO is just like linking against
archive; you should be able to override any symbols in it with your
own" model. The "first instance" of your DSO overrides symbols in
the "second instance".

One way to solve this issue is, naturally, putting the code behind one
namespace, compiling it, changing the namespace and compiling the code
again. Unfortunately, this solution is too costly to implement since
the project contains a large number of files that should be changed.
In addition, this solution will be disposed of in the near future as
the static variables are removed.

Is there a quicker and dirtier way to solve this issue? Maybe some
script or switch to compile all code under a single namespace.

Probably. You didn't specify whether client code depends on any of
the static data being "exported" from the DSO, but given that
"two DLL solution" worked on Win32, the answer is probably no.

In that case, you can hide (make local) all the static data inside
the DSO with a linker script, and achieve behaviour that is exactly
equivalent to what you have on Win32.

Try "info ld" -> Scripts -> VERSION

Cheers,
--
In order to understand recursion you must first understand recursion.
Remove /-nsp/ for email.
.



Relevant Pages

  • Re: RPG Programming on Advanced 36
    ... I see most files using the CATALOG command. ... Catalog shows FILES and Libraries, ... FROMLIBR/TOLIBR will copy "members" within libraries. ... I think the command to compile a program is RPG - it's been ...
    (comp.sys.ibm.sys3x.misc)
  • Re: DDM files and /COPY statements
    ... I'm pretty sure I have the correct authorization. ... It's just depending on the library list if the /COPY members can be ... it isn't looking at the DDM libraries anymore. ...
    (comp.sys.ibm.as400.misc)
  • Re: reading dimension members with DSO
    ... You read dimension members using MDSCHEMA_MEMBERS; not using DSO. ... existing cube) behind your back to provide the browsing experience. ...
    (microsoft.public.sqlserver.olap)
  • LLA and Cobol copybook library
    ... I don't know anything about "Cobol copybook libraries", ... LLA might manage the directory entries for you but LLA caching of members ... For IBM-MAIN subscribe / signoff / archive access instructions, ...
    (bit.listserv.ibm-main)
  • Some members of TypeLib libraries cant be found even in MSDN ?!
    ... Using VS2005 Beta 2 for an MFC project. ... of the many listed members is one called ... This is just an example and it is true for many other members of other ... libraries as well. ...
    (microsoft.public.vc.language)