Re: Building Log4cplus fails with "ld: Unsatisfied symbol virtual table of" (1088 Views)
Reply
Advisor
Pinkerik
Posts: 14
Registered: ‎08-14-2013
Message 1 of 14 (1,168 Views)
Accepted Solution

Building Log4cplus fails with "ld: Unsatisfied symbol virtual table of"

Hello,

I'm trying to compile log4cplus on HP-UX (https://code.launchpad.net/~log4cplus/log4cplus/1.1.x)

$ uname -a
HP-UX migs01a B.11.31 U ia64 0841004181 unlimited-user license

$ aCC --version
aCC: HP C/aC++ B3910B A.06.20 [May 13 2008]

 

Library is compiled just "fine", problem is when it tryes to compile some test program and link created library to it

ld: Unsatisfied symbol "virtual table of loggingserver::ClientThread" in file loggingserver.o
ld: Unsatisfied symbol "virtual table of loggingserver::ClientThread" in file loggingserver.o

 

I suspect that some warnings along library build might cause this error, but I'm not sure

 

Attaching build log from jenkins

 

And btw, on other platforms it compiles OK, even on some realy old AIX

 

Thank you

Frequent Advisor
SoumitraC
Posts: 26
Registered: ‎03-21-2012
Message 2 of 14 (1,141 Views)

Re: Building Log4cplus fails with "ld: Unsatisfied symbol virtual table of"

Can you please pass on the pre-processed .i file for loggingserver.cxx using the command line options -E -.i as shown below:

 

aCC -DHAVE_CONFIG_H    -I../include -I../include  -DNDEBUG -D_GNU_SOURCE=1 -D_REENTRANT  -AA +DD64 -mt -D_REENTRANT  -E -.i loggingserver.cxx
Soumitra C
HP-UX Compilers
Advisor
Pinkerik
Posts: 14
Registered: ‎08-14-2013
Message 3 of 14 (1,129 Views)

Re: Building Log4cplus fails with "ld: Unsatisfied symbol virtual table of"

[ Edited ]

Requested preprocessed file

 

Edit: actualy attaching the file (had to add extension to be able to attach it)

Acclaimed Contributor
Dennis Handly
Posts: 25,283
Registered: ‎03-06-2006
Message 4 of 14 (1,095 Views)

Re: Building Log4cplus fails with "ld: Unsatisfied symbol virtual table of"

[ Edited ]

>ld: Unsatisfied symbol "virtual table of loggingserver::ClientThread"

 

This means that the source file that defines the first non pure, non inline virtual function in the class loggingserver::ClientThread was not linked into the application.

 

I.e. if you have virtual functions in a class, they MUST be defined.

You have virtual functions "run" and ~ClientThread.  I see the definition of both.  But not of start.

Visitor
vzeman79
Posts: 3
Registered: ‎11-07-2013
Message 5 of 14 (1,088 Views)

Re: Building Log4cplus fails with "ld: Unsatisfied symbol virtual table of"

[ Edited ]

Dennis Handly wrote:

>ld: Unsatisfied symbol "virtual table of loggingserver::ClientThread"

 

This means that the source file that defines the first non pure, non inline virtual function in the class loggingserver::ClientThread was not linked into the application.

 

I.e. if you have virtual functions in a class, they MUST be defined.

You have virtual functions "run" and ~ClientThread.  I see the definition of both.  But not of start.


The loggingserver is a single source executable. The loggingserver::ClientThread class is wholy defined in the single source. The start() function is inherited from its base class AbstractThread. The same code works on multiple platforms with different compilers. It even works on HP-UX HPPA with aCC with and without +DD64. I have hard time believing that there is anything wrong with the source itself.

Advisor
Pinkerik
Posts: 14
Registered: ‎08-14-2013
Message 6 of 14 (1,077 Views)

Re: Building Log4cplus fails with "ld: Unsatisfied symbol virtual table of"

But it is defined

in src/threads.cxx at line 411

which is then linked into library, which is then linked to that executable

Acclaimed Contributor
Dennis Handly
Posts: 25,283
Registered: ‎03-06-2006
Message 7 of 14 (1,051 Views)

Re: Building Log4cplus fails with "ld: Unsatisfied symbol virtual table of"

>I have hard time believing that there is anything wrong with the source itself.

 

Looks like the compiler isn't handling __declspec properly?

Some of the construction subobject vtables aren't generated.

 

Compile with: ... "-D__declspec(X)="

Visitor
vzeman79
Posts: 3
Registered: ‎11-07-2013
Message 8 of 14 (1,046 Views)

Re: Building Log4cplus fails with "ld: Unsatisfied symbol virtual table of"


Dennis Handly wrote:

>I have hard time believing that there is anything wrong with the source itself.

 

Looks like the compiler isn't handling __declspec properly?

Some of the construction subobject vtables aren't generated.

 

Compile with: ... "-D__declspec(X)="


Well, how would this help? The ClientThread class in question does not use any of it. It is declared and defined wholy in the same TU.

Acclaimed Contributor
Dennis Handly
Posts: 25,283
Registered: ‎03-06-2006
Message 9 of 14 (1,038 Views)

Re: Building Log4cplus fails with "ld: Unsatisfied symbol virtual table of"

[ Edited ]

>how would this help? The ClientThread class in question does not use any of it. It is declared and defined wholly in the same TU.

 

Because it does?  ;-)

The construction vtables must reference vtables in the base classes.  And it needs to reference AbstractThread::start.

__declspec is confusing the compiler.

Advisor
Pinkerik
Posts: 14
Registered: ‎08-14-2013
Message 10 of 14 (1,018 Views)

Re: Building Log4cplus fails with "ld: Unsatisfied symbol virtual table of"

[ Edited ]

syntax error near unexpected token `('

 

cant define it like that

should I remove exports?

 

Edit:

altering configure file to always set:

ac_cv_declspec=no

ac_cv__attribute__visibility=no

 

allowed me to finaly build it

Visitor
vzeman79
Posts: 3
Registered: ‎11-07-2013
Message 11 of 14 (1,013 Views)

Re: Building Log4cplus fails with "ld: Unsatisfied symbol virtual table of"


Dennis Handly wrote:

>how would this help? The ClientThread class in question does not use any of it. It is declared and defined wholly in the same TU.

 

Because it does?  ;-)

The construction vtables must reference vtables in the base classes.  And it need to reference AbstractThread::start.

__declspec is confusing the compiler.


I am sorry but "don't do it" is not a helpful answer to this problem. Either it is the code that has some kind of problem. If it is the code, then it should be diagnosed and fixed. Or it is the compiler that is buggy and then it should be diagnosed, acknowledge by HP and fixed. And I do not think this problem is in log4cplus' code. Especially since the same code works with HP-PA HP-UX aCC just fine.

 

Advisor
Pinkerik
Posts: 14
Registered: ‎08-14-2013
Message 12 of 14 (1,006 Views)

Re: Building Log4cplus fails with "ld: Unsatisfied symbol virtual table of"

There is definetely problem with those exports

As I mentioned above, if I change either configure or ConfigureChecks.cmake file to not define LOG4CPLUS_DECLSPEC_EXPORT it builds just fine (both autotools and cmake)

Also all the tests pass

 

So for now, fastest solution for me is to add special if to cmake checker

Acclaimed Contributor
Dennis Handly
Posts: 25,283
Registered: ‎03-06-2006
Message 13 of 14 (985 Views)

Re: Building Log4cplus fails with "ld: Unsatisfied symbol virtual table of"

>syntax error near unexpected token `('

 

Hmm, it worked for me but I put it on the compile line and perhaps you need more levels of quoting?

 

>I am sorry but "don't do it" is not a helpful answer to this problem.

 

In this case it was.  Pinkerik was able to build the app.

BTY, it took me a long time to figure this out.

 

>If it is the code, then it should be diagnosed and fixed. Or it is the compiler that is buggy and then it should be diagnosed

 

I don't disagree.  If you have a support contract, please contact the Response Center and file a bug.

 

>Especially since the same code works with aCC3 just fine.

 

Because there is minimal support for declspec.  If you are dumb, there are less things to go wrong.  :-)

Advisor
Pinkerik
Posts: 14
Registered: ‎08-14-2013
Message 14 of 14 (957 Views)

Re: Building Log4cplus fails with "ld: Unsatisfied symbol virtual table of"

Ok we can close this solution as compiler bug
Workaround was provided, so at least something

Thank you for your help
The opinions expressed above are the personal opinions of the authors, not of HP. By using this site, you accept the Terms of Use and Rules of Participation.