4

I received this warning from ld whe I was buliding my program:

ld: warning: direct access in global constructors keyed to _ZN12_GLOBAL__N_143ensure_log_is_created_before_maing_l_filterEto global weak symbol vtable for cs::ObjectFactoryAliasInstantiation<cs::DefaultCommandDispatcher> means the weak symbol cannot be overridden at runtime. This was likely caused by different translation units being compiled with different visibility settings.

The code witch refer the error is this:

class ObjectFactory {
        public :
        ObjectFactory(const char *alias):sAlias(alias){};
        std::string sAlias;
        virtual void* createInstance() = 0;
    };

template <class T>
class ObjectFactoryAliasInstantiation : public ObjectFactory{
public:
    ObjectFactoryAliasInstantiation(const char *alias):ObjectFactory(alias){};
    void* createInstance() { return (void*)new T(&sAlias); };
};`

and this:

        /*
         Class for register the dispatcher for the command
         */
    class CommandDispatcherRegister {  
    public:
        CommandDispatcherRegister(ObjectFactory *commandFactory);
    };

    /*
     Macro for help the Command Dispatcher classes registration
     */
#define REGISTER_AND_DEFINE_COMMAND_DISPATCHER_CLASS(CMD_CLASS_NAME)  class CMD_CLASS_NAME;\
static const CommandDispatcherRegister CMD_CLASS_NAME ## CommandDispatcherRegister(new ObjectFactoryAliasInstantiation<CMD_CLASS_NAME>(#CMD_CLASS_NAME));\
class CMD_CLASS_NAME : public CommandDispatcher\

end this:

 REGISTER_AND_DEFINE_COMMAND_DISPATCHER_CLASS(DefaultCommandDispatcher) {
        bool deinitialized;
Claudio Bisegni
  • 103
  • 2
  • 9

1 Answers1

-2

This was likely caused by different translation units being compiled with different visibility settings.

i.e. you changed some headers and didn't do a full re-build of your whole project. Do that now.

Lightness Races in Orbit
  • 378,754
  • 76
  • 643
  • 1,055
  • i used also scons to be my project(i work with Xcode but distribute it with scons) and i receive this warning also if i run scons -c and then scones. Anyway i'll try again – Claudio Bisegni Oct 16 '11 at 17:24
  • 1
    that's not the warning you'd get from changing a header but from compiling targets with non-matching -fvisibility settings. see http://stackoverflow.com/a/9954259/48125 – nevyn Jul 03 '12 at 12:58