Jump to content
  • Advertisement

Archived

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

nexuz

Exporting/importing static members

This topic is 6026 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
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!