Dealing with "needs to have dll-interface to be used by clients of class"

Started by
12 comments, last by harshman_chris 11 years, 3 months ago

Originally you were exporting the entire singleton class no? That kinda implies you are trying to do this:

// Implementation MUST be in the cpp file (otherwise it gets redefined in the header file in multiple compilation units) template<typename T> T* Singleton<T>::instance = 0;
// and now we export the class specialisations.
template class DLL_EXPORT Singleton<GameInfo>;
template class DLL_EXPORT Singleton<Logger>;
template class DLL_EXPORT Singleton<SoundManager>;
template class DLL_EXPORT Singleton<SceneManager>;
template class DLL_EXPORT Singleton<ResourceManager>;

If you just want to export the variable only, leaving the rest inline, then :


template DLL_EXPORT GameInfo* Singleton<GameInfo>::instance = 0;
template DLL_EXPORT Logger* Singleton<Logger>::instance = 0;
template DLL_EXPORT SoundManager* Singleton<SoundManager>::instance = 0;
template DLL_EXPORT SceneManager* Singleton<SceneManager>::instance = 0;
template DLL_EXPORT ResourceManager* Singleton<ResourceManager>::instance = 0;

Advertisement

A couple of things, I need to replace DLL_EXPORT with PARTICLESENGINE_API from this:


#ifdef PARTICLESENGINE_DLL 
#define PARTICLESENGINE_API __declspec( dllexport )
#else
#define PARTICLESENGINE_API __declspec( dllimport )
#endif

Also there is this error now:


Error 33 error C2143: syntax error : missing ';' before '=' c:\users\100312531\desktop\project-seventeen\particleengineproject\particlesengine\singleton.cpp 12 1 ParticlesEngine

that happens on each of those variable declaration lines

Ahh yup, you might have wanted this instead. My bad!

// Implementation MUST be in the cpp file (otherwise it gets redefined in the header file in multiple compilation units) template<typename T> T* Singleton<T>::instance = 0; template PARTICLESENGINE_API GameInfo* Singleton<GameInfo>::instance; template PARTICLESENGINE_API Logger* Singleton<Logger>::instance; template PARTICLESENGINE_API SoundManager* Singleton<SoundManager>::instance; template PARTICLESENGINE_API SceneManager* Singleton<SceneManager>::instance; template PARTICLESENGINE_API ResourceManager* Singleton<ResourceManager>::instance;

No Worries, thank you for all your help.

There is one more issue left which is similar but different enough to warrant another post, rather than continue this one.

This topic is closed to new replies.

Advertisement