Skip to main content
gamedev.net
🔒 Locked

Exporting/importing static members

Started by nexuz Apr 17, 2002 at 8:14 AM 0 replies 350+ views
Original Post
nexuz
nexuz

  

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).

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.