• Advertisement

Archived

This topic is now archived and is closed to further replies.

Exporting/importing static members

This topic is 5757 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts


  

class EXPORT_API StaticScriptState
{
protected:
    static lua_State* L;
}

// ...and in a .cpp file in the .dll:

lua_State* StaticScriptState::L = NULL;

  
That''s the code. What I''m trying to do here is to export a static member variable from a DLL. It works without any problems to export the variable. The problems comes when i try to import the DLL. The linker then complains that it can''t find the symbol.
client.obj : error LNK2001: unresolved external symbol "protected: static lua_State *  StaticScriptState::L" (?L@StaticScriptState@@1PAXA)
 
I have tried to define the symbol in the client application to and then it works to compile but what happens is that two seperate static variables are created (one for the client and one for the DLL). Does anyone have any idea about how to solve this? (BTW, the variable need to be static because it''s used by static functions in classes that inherit from StaticScriptState).

Share this post


Link to post
Share on other sites
Advertisement

  • Advertisement