unable to create the pointer object of a class at run-time (gcc weaklinking of object)

Discussion in 'C++' started by rippul, Nov 22, 2010.

  1. rippul

    rippul Guest

    Hi,

    Here is my problem,

    Our project is initially written in C due to making compatibility with
    the 3rd party API that we are using.
    Later on due to addition of new features developers added these
    features in C++ code. Hence we converted all of our C file to CPP by
    changing their c extension to cpp and by some minor changes.

    Our code structure is as follows,
    Basically we have around 6 sub modules (which are common to) which we
    are building as a static library and later we are linking all these 6
    archives along with the 3rd party libraries to create a shared object.
    Here is the compiler command line options that we are using
    ============================================================
    /usr/bin/c++ -o ../../bin/Linux/ds-wac-apache2.2.so apache2.2Entry.o
    -shared -L../../lib/Linux -lwac_common -lea_connpool -lea_message -
    ltcp -lds_logs -ltcp -lds_logs -lwac_shmem -Wl,-G -L/usr/lib/gcc/i386-
    redhat-linux/3.4.3 -lstdc++ -L../../../../../../../3rd_party/
    Mozilla_SDK/6.0.6/UNIX/RedHatLinux-4/Mozilla_SDK/lib -lnss3 -
    lnssutil3 -lldif60 -lldap60 -lssldap60 -lprldap60 -lssl3 -lplc4 -
    lplds4 -lnspr4 -lsoftokn3 -lsqlite3 -L../../../../../../../3rd_party/
    openssl/0.9.8d/UNIX/RedHatLinux-4/openssl/lib -lssl -lcrypto -
    lpthread
    ============================================================
    But the problem is that when we are loading our shared library at the
    run time our code stops processing at the particular line that we
    checked with the generated trace file, which is something lime

    “CAccessLog *pAccessLog = new CAccessLog();”.

    We checked with the nm command about the class constructor
    (CAccessLog) it is showing as weak object.

    In our code we are creating an object of a class(pAccessLog) from a
    file which is originally in C, now we converted the extension to cpp.
    I have attached the output of the nm command (nm -a * *.a | grep
    CAccessLog)

    ============================================================================
    00000000 d .data.rel.ro._ZTI10CAccessLog
    00000000 d .data.rel.ro._ZTV10CAccessLog
    00000000 r .rodata._ZTS10CAccessLog
    00000000 T _ZN10CAccessLog10initializeEv
    00000690 T _ZN10CAccessLog12setAuthLevelEPKc
    000001e0 T _ZN10CAccessLog13getLogMessageEv
    00000080 T _ZN10CAccessLog14getSignMessageEv
    00000630 T _ZN10CAccessLog14setDescriptionEPKc
    00000750 T _ZN10CAccessLog15setWebServiceCnEPKc
    000007b0 T _ZN10CAccessLog15setWebServiceDnEPKc
    000005d0 T _ZN10CAccessLog16setGrantedAccessEPKc
    00000550 T _ZN10CAccessLog16setGrantedAccessEb
    00000040 T _ZN10CAccessLog19encodeAccessLogDataEPc
    000006f0 T _ZN10CAccessLog6setURLEPKc
    00000810 T _ZN10CAccessLog9setUserIpEPKc
    00000a10 T _ZN10CAccessLogC1Ev
    00000a70 T _ZN10CAccessLogC2Ev
    00000870 T _ZN10CAccessLogD1Ev
    00000940 T _ZN10CAccessLogD2Ev
    00000000 V _ZTI10CAccessLog
    00000000 V _ZTS10CAccessLog
    00000000 V _ZTV10CAccessLog
    000000a0 T _Z17populateAccessLogP10CAccessLogP10AuthData_tPc
    U _Z18SubmitWACAccessLogPc
    U _ZN10CAccessLog12setAuthLevelEPKc
    U _ZN10CAccessLog13getLogMessageEv
    U _ZN10CAccessLog14setDescriptionEPKc
    U _ZN10CAccessLog15setWebServiceCnEPKc
    U _ZN10CAccessLog15setWebServiceDnEPKc
    U _ZN10CAccessLog16setGrantedAccessEb
    U _ZN10CAccessLog19encodeAccessLogDataEPc
    U _ZN10CAccessLog6setURLEPKc
    U _ZN10CAccessLog9setUserIpEPKc
    U _ZN10CAccessLogC1Ev
    U _ZN10CAccessLogD1Ev
    U _Z18SubmitWACAccessLogPc
    00000000 d .data.rel.ro._ZTI10CAccessLog
    00000000 d .data.rel.ro._ZTV10CAccessLog
    00000000 r .rodata._ZTS10CAccessLog
    00000000 T _ZN10CAccessLog10initializeEv
    00000690 T _ZN10CAccessLog12setAuthLevelEPKc
    000001e0 T _ZN10CAccessLog13getLogMessageEv
    00000080 T _ZN10CAccessLog14getSignMessageEv
    00000630 T _ZN10CAccessLog14setDescriptionEPKc
    00000750 T _ZN10CAccessLog15setWebServiceCnEPKc
    000007b0 T _ZN10CAccessLog15setWebServiceDnEPKc
    000005d0 T _ZN10CAccessLog16setGrantedAccessEPKc
    00000550 T _ZN10CAccessLog16setGrantedAccessEb
    00000040 T _ZN10CAccessLog19encodeAccessLogDataEPc
    000006f0 T _ZN10CAccessLog6setURLEPKc
    00000810 T _ZN10CAccessLog9setUserIpEPKc
    00000a10 T _ZN10CAccessLogC1Ev
    00000a70 T _ZN10CAccessLogC2Ev
    00000870 T _ZN10CAccessLogD1Ev
    00000940 T _ZN10CAccessLogD2Ev
    00000000 V _ZTI10CAccessLog
    00000000 V _ZTS10CAccessLog
    00000000 V _ZTV10CAccessLog
    000000a0 T _Z17populateAccessLogP10CAccessLogP10AuthData_tPc
    U _Z18SubmitWACAccessLogPc
    U _ZN10CAccessLog12setAuthLevelEPKc
    U _ZN10CAccessLog13getLogMessageEv
    U _ZN10CAccessLog14setDescriptionEPKc
    U _ZN10CAccessLog15setWebServiceCnEPKc
    U _ZN10CAccessLog15setWebServiceDnEPKc
    U _ZN10CAccessLog16setGrantedAccessEb
    U _ZN10CAccessLog19encodeAccessLogDataEPc
    U _ZN10CAccessLog6setURLEPKc
    U _ZN10CAccessLog9setUserIpEPKc
    U _ZN10CAccessLogC1Ev
    U _ZN10CAccessLogD1Ev
    U _Z18SubmitWACAccessLogPc
    ============================================================================

    I am also some confused by this kind of the output that I cant
    understand easily.
    Can someone Please help me on the same.
    Any help will be hearty appreciated.
     
    rippul, Nov 22, 2010
    #1
    1. Advertising

  2. Re: unable to create the pointer object of a class at run-time (gccweak linking of object)

    On 11/22/2010 12:57 AM, rippul wrote:
    > Our project is initially written in C due to making compatibility with
    > the 3rd party API that we are using.
    > Later on due to addition of new features developers added these
    > features in C++ code. Hence we converted all of our C file to CPP by
    > changing their c extension to cpp and by some minor changes.
    >
    > Our code structure is as follows,
    > Basically we have around 6 sub modules (which are common to) which we
    > are building as a static library and later we are linking all these 6
    > archives along with the 3rd party libraries to create a shared object.
    > Here is the compiler command line options that we are using
    > ============================================================
    > [..off-topic snipped..]
    > ============================================================
    > But the problem is that when we are loading our shared library at the


    FYI, "shared library" isn't defined by the language.

    > run time our code stops processing at the particular line that we
    > checked with the generated trace file, which is something lime
    >
    > “CAccessLog *pAccessLog = new CAccessLog();”.
    >
    > We checked with the nm command about the class constructor
    > (CAccessLog) it is showing as weak object.


    "Weak object" isn't defined either.

    > In our code we are creating an object of a class(pAccessLog) from a
    > file which is originally in C, now we converted the extension to cpp.


    If you think your problem is in C++ *code*, post the damn *code*. If
    you think it has something to do with mechanisms outside of the language
    itself (like shared libraries), then don't post code.

    > I have attached the output of the nm command (nm -a * *.a | grep
    > CAccessLog)


    'nm' is not defined by the language.

    >
    > ============================================================================
    > [..off-topic snipped..]
    > ============================================================================
    >
    > I am also some confused by this kind of the output that I cant
    > understand easily.
    > Can someone Please help me on the same.
    > Any help will be hearty appreciated.


    Perhaps you should post to the newsgroup where your concerns (shared
    libraries and 'nm' and "weak objects") are on topic, like the newsgroup
    dedicated to your *operating system*. Consider that if your problem can
    exist on more than one operating system, there are also newsgroups
    dedicated to *compilers*.

    Your problem cannot be answered in terms of the C++ *language* alone, so
    it is really *off-topic* here, sorry.

    V
    --
    I do not respond to top-posted replies, please don't ask
     
    Victor Bazarov, Nov 22, 2010
    #2
    1. Advertising

  3. rippul

    Jorgen Grahn Guest

    Re: unable to create the pointer object of a class at run-time (gccweak linking of object)

    On Mon, 2010-11-22, rippul wrote:
    > Hi,
    >
    > Here is my problem,
    >
    > Our project is initially written in C due to making compatibility with
    > the 3rd party API that we are using.


    Odd; C++ code can use pretty much the same libraries as C code can.

    > Later on due to addition of new features developers added these
    > features in C++ code. Hence we converted all of our C file to CPP


    You mean C++ here, not CPP (the C pre-processor).

    ....
    > I have attached the output of the nm command (nm -a * *.a | grep
    > CAccessLog)

    ....
    > 000001e0 T _ZN10CAccessLog13getLogMessageEv
    > 00000080 T _ZN10CAccessLog14getSignMessageEv

    ....
    > I am also some confused by this kind of the output that I cant
    > understand easily.


    It is called "name mangling" and is a method for making C++ compatible
    with general-purpose linkers. Your nm probably has an option for
    decoding such names and making them eminently readable! Read the
    manual.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Nov 23, 2010
    #3
  4. rippul

    Jorgen Grahn Guest

    Re: unable to create the pointer object of a class at run-time (gccweak linking of object)

    On Tue, 2010-11-23, Pete Becker wrote:
    > On 2010-11-23 11:05:49 -0500, Jorgen Grahn said:
    >
    >> On Mon, 2010-11-22, rippul wrote:

    ....

    >>> Later on due to addition of new features developers added these
    >>> features in C++ code. Hence we converted all of our C file to CPP

    >>
    >> You mean C++ here, not CPP (the C pre-processor).

    >
    > No, almost certainly CPP, the file extension.


    OK, then he meant "renamed", not "converted".

    >> ...
    >>> I have attached the output of the nm command (nm -a * *.a | grep
    >>> CAccessLog)

    >> ...
    >>> 000001e0 T _ZN10CAccessLog13getLogMessageEv
    >>> 00000080 T _ZN10CAccessLog14getSignMessageEv

    >> ...
    >>> I am also some confused by this kind of the output that I cant
    >>> understand easily.

    >>
    >> It is called "name mangling" and is a method for making C++ compatible
    >> with general-purpose linkers. Your nm probably has an option for
    >> decoding such names and making them eminently readable! Read the
    >> manual.

    >
    > Of course, that won't solve the problem.


    Which problem? Rippul had a hard time reading names like
    _ZN10CAccessLog14getSignMessageEv, and that's what I was trying to
    help him with.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Nov 25, 2010
    #4
  5. rippul

    Jorgen Grahn Guest

    Re: unable to create the pointer object of a class at run-time (gccweak linking of object)

    On Thu, 2010-11-25, Pete Becker wrote:
    > On 2010-11-25 11:57:55 -0500, Jorgen Grahn said:
    >
    >> On Tue, 2010-11-23, Pete Becker wrote:
    >>> On 2010-11-23 11:05:49 -0500, Jorgen Grahn said:
    >>>
    >>>> On Mon, 2010-11-22, rippul wrote:


    >>>> ...
    >>>>> I have attached the output of the nm command (nm -a * *.a | grep
    >>>>> CAccessLog)
    >>>> ...
    >>>>> 000001e0 T _ZN10CAccessLog13getLogMessageEv
    >>>>> 00000080 T _ZN10CAccessLog14getSignMessageEv
    >>>> ...
    >>>>> I am also some confused by this kind of the output that I cant
    >>>>> understand easily.
    >>>>
    >>>> It is called "name mangling" and is a method for making C++ compatible
    >>>> with general-purpose linkers. Your nm probably has an option for
    >>>> decoding such names and making them eminently readable! Read the
    >>>> manual.
    >>>
    >>> Of course, that won't solve the problem.

    >>
    >> Which problem? Rippul had a hard time reading names like
    >> _ZN10CAccessLog14getSignMessageEv, and that's what I was trying to
    >> help him with.
    >>

    >
    > Um, the link error?


    Maybe we misunderstand each other in some way ... He quoted mangled
    symbols and said he was "confused by this kind of the output that I
    cant understand easily". So I told him about name mangling and that
    it can be decoded. Is there anything wrong with that?

    > Which, unfortunately, is no longer in the
    > attributions of this message.


    Last time I checked, it was ok to pick one issue in a posting,
    concentrate on that one, and trim unrelated parts. And that's what I
    did.

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Nov 27, 2010
    #5
  6. rippul

    Jorgen Grahn Guest

    Re: unable to create the pointer object of a class at run-time (gccweak linking of object)

    On Sat, 2010-11-27, Pete Becker wrote:
    > On 2010-11-27 05:45:40 -0500, Jorgen Grahn said:
    >
    >> On Thu, 2010-11-25, Pete Becker wrote:
    >>> On 2010-11-25 11:57:55 -0500, Jorgen Grahn said:
    >>>
    >>>> On Tue, 2010-11-23, Pete Becker wrote:
    >>>>> On 2010-11-23 11:05:49 -0500, Jorgen Grahn said:
    >>>>>
    >>>>>> On Mon, 2010-11-22, rippul wrote:

    >>
    >>>>>> ...
    >>>>>>> I have attached the output of the nm command (nm -a * *.a | grep
    >>>>>>> CAccessLog)
    >>>>>> ...
    >>>>>>> 000001e0 T _ZN10CAccessLog13getLogMessageEv
    >>>>>>> 00000080 T _ZN10CAccessLog14getSignMessageEv
    >>>>>> ...
    >>>>>>> I am also some confused by this kind of the output that I cant
    >>>>>>> understand easily.
    >>>>>>
    >>>>>> It is called "name mangling" and is a method for making C++ compatible
    >>>>>> with general-purpose linkers. Your nm probably has an option for
    >>>>>> decoding such names and making them eminently readable! Read the
    >>>>>> manual.
    >>>>>
    >>>>> Of course, that won't solve the problem.
    >>>>
    >>>> Which problem? Rippul had a hard time reading names like
    >>>> _ZN10CAccessLog14getSignMessageEv, and that's what I was trying to
    >>>> help him with.
    >>>>
    >>>
    >>> Um, the link error?

    >>
    >> Maybe we misunderstand each other in some way ... He quoted mangled
    >> symbols and said he was "confused by this kind of the output that I
    >> cant understand easily". So I told him about name mangling and that
    >> it can be decoded. Is there anything wrong with that?
    >>
    >>> Which, unfortunately, is no longer in the
    >>> attributions of this message.

    >>
    >> Last time I checked, it was ok to pick one issue in a posting,
    >> concentrate on that one, and trim unrelated parts. And that's what I
    >> did.
    >>

    >
    > You snipped the part that addressed the link error, which was the
    > underlying problem, then asked what problem I was referring to. Now you
    > claim that that's legitimate discussion? No wonder you're lost.


    I'm not lost. I found your "of course, that won't solve the problem"
    above condescending.

    I cannot formulate it simpler than this: When someone complains about
    a major problem A and also a smaller, unrelated problem B, and someone
    helps him with problem B, you don't step in and exclaim "But that
    doesn't solve A!"

    /Jorgen

    --
    // Jorgen Grahn <grahn@ Oo o. . .
    \X/ snipabacken.se> O o .
     
    Jorgen Grahn, Nov 28, 2010
    #6
  7. rippul

    Öö Tiib Guest

    Re: unable to create the pointer object of a class at run-time (gccweak linking of object)

    On Nov 28, 3:22 pm, Pete Becker <> wrote:
    > On 2010-11-28 02:13:10 -0500, Jorgen Grahn said:
    >
    >
    >
    > > I cannot formulate it simpler than this: When someone complains about
    > > a major problem A and also a smaller, unrelated problem B, and someone
    > > helps him with problem B, you don't step in and exclaim "But that
    > > doesn't solve A!"

    >
    > Seems to me that it's more important to point out ways to solve the
    > major problem.


    But that Victor Bazarov already did in else thread.

    Calm down, why to bash each other because of rippul? He can't
    understand what his development tools do. Cant tell what happens
    "stopped processing". Can't track the reasons "weak objects". Your
    arguing leaves him as clueless as before.

    The problem A is that they voodoo-bang there 6 somethings that are not
    C nor C++ together, link it as shared library and try to load that and
    see what happens. No unit tests whatsoever and no one in company who
    can fix a simple crash. The mysterious "third party library" seems to
    be openssl. Its usage indicates some security requirements. Most
    secure is perhaps present situation when their software does not start
    at all.
     
    Öö Tiib, Nov 28, 2010
    #7
  8. rippul

    Öö Tiib Guest

    Re: unable to create the pointer object of a class at run-time (gccweak linking of object)

    On Nov 28, 6:59 pm, Pete Becker <> wrote:
    > On 2010-11-28 09:22:53 -0500, Tiib said:
    >
    > > On Nov 28, 3:22 pm, Pete Becker <> wrote:
    > >> On 2010-11-28 02:13:10 -0500, Jorgen Grahn said:

    >
    > >>> I cannot formulate it simpler than this: When someone complains about
    > >>> a major problem A and also a smaller, unrelated problem B, and someone
    > >>> helps him with problem B, you don't step in and exclaim "But that
    > >>> doesn't solve A!"

    >
    > >> Seems to me that it's more important to point out ways to solve the
    > >> major problem.

    >
    > > But that Victor Bazarov already did in else thread.

    >
    > And I did, too, "else thread".


    You did too, yes. Only one thing ... isn't missing extern "C" usually
    causing link-time, not run-time problems? rippul clearly stated run-
    time in subject. His terminology was odd overall, so who can know, you
    may be right and the actual issue was about that extern "C" indeed.
     
    Öö Tiib, Nov 28, 2010
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. =?Utf-8?B?TGFsaXQ=?=
    Replies:
    1
    Views:
    407
    Karl Seguin
    Dec 22, 2004
  2. Replies:
    8
    Views:
    441
  3. flamesrock
    Replies:
    8
    Views:
    502
    Hendrik van Rooyen
    Nov 24, 2006
  4. Pierre Yves
    Replies:
    2
    Views:
    499
    Pierre Yves
    Jan 10, 2008
  5. Michel

    Create a class at run-time

    Michel, Mar 25, 2010, in forum: Python
    Replies:
    8
    Views:
    313
    Steve Holden
    Mar 26, 2010
Loading...

Share This Page