Boost logo

Boost Users :

From: NFarnsworth_at_[hidden]
Date: 2008-02-01 12:06:34


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<Singleton ,1,factorylib_tag >
{
        public:
        CPP_API Singleton (boost::restricted);
&#8230;
BOOST_SINGLETON_PLACEMENT_DECLARATION
&#8230;
}
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<DataPoolManagerImpl,2,datapoollib_tag>
{

Then I will get the following error message:

boost\utility\mutexed_singleton.hpp(212) : error C2248: "boost::mutexed_singleton<Derived,DisposalSlot>::instance_proxy": cannot access private class, which is declared in boost::mutexed_singleton<Derived,DisposalSlot>

with
[
Derived=DataPoolManagerImpl,
DisposalSlot=2
]
\boost\utility\mutexed_singleton.hpp(41): see declaration of 'boost::mutexed_singleton<Derived,DisposalSlot>::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<Derived,DisposalSlot,SubsystemTag>::instance_proxy boost::mutexed_singleton<Derived,DisposalSlot,SubsystemTag>::instance".

with
[
Derived=DataPoolManagerImpl,
DisposalSlot=2,
SubsystemTag=datapoollib_tag
]
\datapoolmanager.h(43): see reference of instantiation of compiled class template "boost::mutexed_singleton<Derived,DisposalSlot,SubsystemTag>".

with
[
DataPoolManagerImpl,
DisposalSlot=2,
datapoollib_tag
]
\boost\utility\mutexed_singleton.hpp(212) : error C2440: Initialization': 'boost::mutexed_singleton<Derived,DisposalSlot>::instance_proxy' could not converted in 'boost::mutexed_singleton<Derived,DisposalSlot,SubsystemTag>::instance_proxy'

with
[
Derived=DataPoolManagerImpl,
DisposalSlot=2
]

With :
 class DataPoolManagerImpl : public boost::singleton<DataPoolManagerImpl,2,datapoollib_tag>
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
_____________________________________________________________________
Unbegrenzter Speicherplatz für Ihr E-Mail Postfach? Jetzt aktivieren!
http://www.digitaledienste.web.de/freemail/club/lp/?lp=7


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net