Unresolved external symbol static variable (variable used by method defined in header)

前端 未结 3 768
梦如初夏
梦如初夏 2021-01-19 13:07

Here is the .h:

class Logger
{
private:
    static int mTresholdSeverity;

public:
    static __declspec(dllexport) void log(const char* message);
    static         


        
3条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-19 13:31

    The problem is that mThresholdSeverity is not exported from the DLL, but the two accessors are defined inline, so wherever they're called they have to be able to see mThresholdSeverity. There are two solutions: either export mThresholdSeverity from the DLL (sorry, I don't remember how to do that off the top of my head), or make the accessors non-inline functions, define them in the DLL, and export them from the DLL.

提交回复
热议问题