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

David Aldrich david.aldrich.ntml@gmail.com
Thu Dec 13 22:21:00 GMT 2018


>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@gmail.com>
wrote:

> On Thu, 13 Dec 2018 at 16:01, David Aldrich
> <david.aldrich.ntml@gmail.com> 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.
>



More information about the Gcc-help mailing list