Re: What might cause 'undefined symbol' for typeinfo when loading dynamic library built with C++11 enabled?

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

 



>If you use them in a way that requires an object with storage (e.g.
>take their address or bind a reference to them) then yes. See
>https://gcc.gnu.org/wiki/VerboseDiagnostics#missing_static_const_definition

Thanks for the link. That fixed the missing symbol error.

>Both your errors are linker errors due to missing symbols, but the
>causes are entirely different. The only way they could have the same
>cause is if you're forgetting to link to the file that contains those
>symbols.

The typeinfo error has now gone. I realise that is surprising, but I'm
happy with the result.

Thanks again for your help.

On Thu, Dec 13, 2018 at 4:04 PM Jonathan Wakely <jwakely.gcc@xxxxxxxxx>
wrote:

> On Thu, 13 Dec 2018 at 16:01, David Aldrich
> <david.aldrich.ntml@xxxxxxxxx> wrote:
> >
> > Thank you Jonathan for your reply.
> >
> > The class does indeed contain a virtual method, but that method is
> defined.
> > So I don't think that is the problem.
> >
> > I've disabled the loading of the troublesome .so library file and now
> > another library is refusing to load. I am wondering whether this new
> > problem is related and so would like to ask you about it.  The error
> > message now is:
> >
> > undefined symbol: _ZN8StarLibs7LinkSim2NR6NRDmrs18MAX_NUM_CDM_GROUPSE (
> > StarLibs::LinkSim::NR::NRDmrs::MAX_NUM_CDM_GROUPS )
> >
> > This symbol is a constant defined in a class's header (.h file):
> >
> > namespace StarLibs {
> > namespace LinkSim {
> > namespace NR
> > {
> > class NRDmrs
> > {
> > public:
> >
> >         static const unsigned DMSR_MAX_NSCID = 1;
> >         static const unsigned MAX_NUM_CDM_GROUPS = 3;
> >
> > This takes me back to my earlier comment.  In C++14, do I need to declare
> > such constants in a .cpp source file in order to give them storage and so
> > make them load?
>
> If you use them in a way that requires an object with storage (e.g.
> take their address or bind a reference to them) then yes. See
> https://gcc.gnu.org/wiki/VerboseDiagnostics#missing_static_const_definition
>
> Both your errors are linker errors due to missing symbols, but the
> causes are entirely different. The only way they could have the same
> cause is if you're forgetting to link to the file that contains those
> symbols.
>



[Index of Archives]     [Linux C Programming]     [Linux Kernel]     [eCos]     [Fedora Development]     [Fedora Announce]     [Autoconf]     [The DWARVES Debugging Tools]     [Yosemite Campsites]     [Yosemite News]     [Linux GCC]

  Powered by Linux