[Top][All Lists]

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Undefined symbol when loading g++ created library

From: Adam Nielsen
Subject: Re: Undefined symbol when loading g++ created library
Date: Mon, 28 Nov 2005 09:45:25 +1000

> Right.  If there are no instances of RootClass in your main, it is
> possible that the constructor won't get linked in the main's
> executable

Aha!  I think this might be the problem.  Although the RootClass
constructor is defined in Main, it's never actually called from within
Main.  Only the Plugin library will call this constructor, so it looks
like the code is indeed being omitted from Main at link time.

> Eg if you have a *static* library (libmumble.a) containing the
> constructor of RootClass, the linker might not have a reason to
> include the code for the constructor if it is not referenced by the
> main program.

The constructor is implemented in the main executable, e.g.

  g++ -o main Main.o RootClass.o

But I imagine it's the same situation.

> depending on how you linked things.

Is there a way I can link things so this code would be included?  Or
will I need to 'fudge' some code that creates a RootClass so the linker
includes it in the executable?


reply via email to

[Prev in Thread] Current Thread [Next in Thread]