Jump to content
  • Advertisement

Archived

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

McZ

sharing a static member between .dll's

This topic is 5165 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

well.. I have an abstract plugin class in one .dll file and I want to create a real class out of that one in another .dll file when I compile the plugin the linker complains that the cPluginBase::Tools is undefind or something like that if I remove that line everything works perfect.
// -- a tool structure

struct sTools {

 // here is some different type of functions/members

 // the plugins may acces 

 cTextureManager *TextureManager;
 ...

};

// -- in main.dll I have this abstract class

class DLL_API cPluginBase {

 // some usefull stuff


public:

 // define the tools so that the plugins can acces some

 // tool functions through Tools.SomeFunction(...);

 static sTools Tools;

 // virtual functions

 ...

};

// -- defined in the .cpp file

sTools cPluginBase::Tools;


// -- this is defined in my plugin.dll file

class DLL_API cMyNewPlugin : public cPluginBase {
public:

 // well the real implementation of the virtual functions

 ...
};

I want to use this so I can add pointers to something to the cPluginBase::Tools.somepointer; e.g. cPluginBase::Tools.TextureManager = RenderSystem->GetTextureManager(); at the moment I have to add the textuer manager to every plugin, like this: for( p=each plugin in list) { p->AttachTextureManager( RenderSystem->GetTextureManager() ); }

Share this post


Link to post
Share on other sites
Advertisement
You need to export the static variable too, like this


// -- defined in the .cpp

DLL_API filesTools cPluginBase::Tools;

Share this post


Link to post
Share on other sites
Have you tried exporting the declaration for the sTools structure? You say it has functions in it. Unless they are all inlined, it needs to be exported\imported as well as the static instance in the translation unit.

Hope that''s it.

- Jason Citron
- Team nine:14, System Architect
- www.nine14.net
--------------------------------------------------
Checkout the prototype of Fates Forgiven at www.fatesforgiven.com

Share this post


Link to post
Share on other sites

  • 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!