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 forcs::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;