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

R

rippul

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.
 
V

Victor Bazarov

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
 
J

Jorgen Grahn

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
 
J

Jorgen Grahn

....


No, almost certainly CPP, the file extension.

OK, then he meant "renamed", not "converted".
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
 
J

Jorgen Grahn

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
 
J

Jorgen Grahn

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
 
Ö

Öö Tiib

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

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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,981
Messages
2,570,187
Members
46,729
Latest member
ScarlettJe

Latest Threads

Top