I'm working on getting rLog to build as a DLL under windows, and I was getting undefined symbol errors relating to some global symbols in the rlog namespace. Specifically these in RLogChannel.cpp:
namespace rlog {
...
RLogChannel *_RLDebugChannel = GetGlobalChannel( "debug", Log_Debug );
RLogChannel *_RLInfoChannel = GetGlobalChannel( "info", Log_Info );
RLogChannel *_RLWarningChannel = GetGlobalChannel( "warning", Log_Warning );
RLogChannel *_RLErrorChannel = GetGlobalChannel( "error", Log_Error );
...
};
I assumed the problem was that 1) they weren't exported and 2) they weren't declared in the header so other things can access them. So I added a __declspec(dllexport) (via the RLOG_DECL macro) to them, and in the header, put:
namespace rlog {
...
RLOG_DECL extern RLogChannel *_RLDebugChannel;
RLOG_DECL extern RLogChannel *_RLInfoChannel;
RLOG_DECL extern RLogChannel *_RLWarningChannel;
RLOG_DECL extern RLogChannel *_RLErrorChannel;
...
};
But no matter how I declare the variables in RLogChannel.cpp I get a redefinition error, despite my externing them in the header... What's the right way to do this? Seems like it should be straightforward but I can't quite wrap my head around it.
Edit: error message
Error 12 error C2086: 'rlog::RLogChannel *rlog::_RLDebugChannel' : redefinition rlog-1.4\rlog\RLogChannel.cpp 45 rlog
(same for all 4 symbols)
Edit: I don't know what happened, the code is exactly the same before but now it will compile (feels like MSVC weirdness...), unfortunately the symbols still show up as unresolved when linking into my library