Je déclare un singleton sur une DLL d'extension MFC, comme ceci:Singleton extension MFC DLL
//header file: SingleTon.h class AFX_EXT_CLASS CMySingleton { public: static CMySingleton* Instance() { if(!singleton) singleton = new CMySingleton(); return singleton; } int a; // Other non-static member functions private: CMySingleton() {}; // Private constructor CMySingleton(const CMySingleton&); // Prevent copy-construction CMySingleton& operator=(const CMySingleton&); // Prevent assignment virtual ~CMySingleton() {}; static CMySingleton* singleton; }; And in a cpp file I code the following line: CMySingleton* CMySingleton::singleton = NULL;
Code 2:
CMySingleton *a; a = CMySingleton::Instance();
Le problème est quand je code "Code 2" dans un régulier dll, tout fonctionne très bien, mais quand je code "code 2" dans un autre DLL d'extension MFC donne une erreur:
unresolved external symbol "private: static class CMySingleton* CMySingleton::singleton" ([email protected]@@[email protected])
Je vérifie correctement tous les dependenci es, via les dépendances du projet.
Une idée?
Grande réponse !!. –