
Hello, Unfortunately I still need help with these problems please. Is there anybody who could explain me how to use the Boost.Utilty/Singleton with dlls? The test examples of the singleton didn't clearify for me, how I can do this. Best regards Niklas
Hello, I want to use the Boost.Utility/Singleton together with dll's. I use the Visual Studio 2005 and Windows XP. I have three dynamic libraries. In library A the Singleton is implemented and library B and C access to the Singleton. The dynamic libraries B and C
are compiled with the clr compiler Option. The Problem is, that the Singleton will be twice instantiated when library A and B access to the singleton.
The singleton declaration looks like the following code: //Singleton.h class Singleton : public boost::singleton
{ public: CPP_API Singleton (boost::restricted); … BOOST_SINGLETON_PLACEMENT_DECLARATION … } CPP_API is a definition of the dll export. #if defined( _WIN32 ) && defined( _MSC_VER ) # if defined SINGLETON_EXPORTS # define CPP_API __declspec( dllexport ) # else # define CPP_API __declspec( dllimport ) # pragma warning( disable : 4251 ) // 'identifier' : class 'type' needs to have dll-interface to be used by clients of class 'type2'
# endif #endif
In the Project properties of library B and C in "additional linkage input" I included the import library of the dll A.
Another problem is, that the application crashes when I close the application. The crash happens in C.dll!_CRT_INIT(void * hDllHandle=0x0f8b0000, unsigned long dwReason=0, void * lpreserved=0x00000001) line 420 -> _free_crt ( onexitbegin ) ; And also : B.dll!_CRT_INIT(void * hDllHandle=0x0f8b0000, unsigned long dwReason=0, void * lpreserved=0x00000001) line 420 -> _free_crt ( onexitbegin ) ; If I don't use the singleton, the application will not crash.
Another Problem is, that I can not compile the following code:
class DataPoolManagerImpl : public boost::mutexed_singleton
{ Then I will get the following error message:
boost\utility\mutexed_singleton.hpp(212) : error C2248: "boost::mutexed_singleton
::instance_proxy": cannot access private class, which is declared in boost::mutexed_singleton with [ Derived=DataPoolManagerImpl, DisposalSlot=2 ] \boost\utility\mutexed_singleton.hpp(41): see declaration of 'boost::mutexed_singleton
::instance_proxy' with [ Derived=DataPoolManagerImpl, DisposalSlot=2 ] \boost\utility\mutexed_singleton.hpp(211): During compiling the class template of the static data member "const boost::mutexed_singleton
::instance_proxy boost::mutexed_singleton ::instance". with [ Derived=DataPoolManagerImpl, DisposalSlot=2, SubsystemTag=datapoollib_tag ] \datapoolmanager.h(43): see reference of instantiation of compiled class template "boost::mutexed_singleton
". with [ DataPoolManagerImpl, DisposalSlot=2, datapoollib_tag ] \boost\utility\mutexed_singleton.hpp(212) : error C2440: Initialization': 'boost::mutexed_singleton
::instance_proxy' could not converted in 'boost::mutexed_singleton ::instance_proxy' with [ Derived=DataPoolManagerImpl, DisposalSlot=2 ]
With : class DataPoolManagerImpl : public boost::singleton
There are no compiler errors. Could you tell me how I can solve these problems please? Thank you for your help in advance and best regards Niklas
_______________________________________________________________________ Jetzt neu! Schützen Sie Ihren PC mit McAfee und WEB.DE. 30 Tage kostenlos testen. http://www.pc-sicherheit.web.de/startseite/?mc=022220