DLL's with STL problem - Programmer

This is a discussion on DLL's with STL problem - Programmer ; I am trying to put some classes in a DLL and use the STL libraries too, the list class inpaticular is giving trouble, thus: class __declspec( dllexport ) CTEngine; class CTEngine { public: static CTEngine *LoadGraph( istream &i ); private: ...

+ Reply to Thread
Results 1 to 4 of 4

Thread: DLL's with STL problem

  1. DLL's with STL problem

    I am trying to put some classes in a DLL and use the STL libraries too, the
    list class inpaticular is giving trouble, thus:

    class __declspec( dllexport ) CTEngine;

    class CTEngine
    {
    public:
    static CTEngine *LoadGraph( istream &i );
    private:
    list GraphList;
    CTEngine();
    };

    ct.h(20) : warning C4251: 'CTEngine::GraphList' : class 'std::list<_Ty,_Ax>'
    needs to have dll-interface to be used by clients of class 'CTEngine'
    with
    [
    _Ty=CTNode *,
    _Ax=std::allocator
    ]



  2. Re: DLL's with STL problem

    I found this:
    http://support.microsoft.com/default...NoWebContent=1

    Which seems to mean you can't use STL wtih DLL's. And it may also mean it's
    difficult to use C++ with dll's aswell. Is that right?

    I want to write a portable application, split into dll's. Presumably two
    possibilities now are: Write it in C, or compile it as one large executable?



  3. Re: DLL's with STL problem

    "Spacen Jasset" wrote in message

    > I am trying to put some classes in a DLL and use the STL libraries too,

    the
    > list class inpaticular is giving trouble, thus:
    >
    > class __declspec( dllexport ) CTEngine;
    >
    > class CTEngine
    > {
    > public:
    > static CTEngine *LoadGraph( istream &i );
    > private:
    > list GraphList;
    > CTEngine();
    > };
    >
    > ct.h(20) : warning C4251: 'CTEngine::GraphList' : class

    'std::list<_Ty,_Ax>'
    > needs to have dll-interface to be used by clients of class 'CTEngine'
    > with
    > [
    > _Ty=CTNode *,
    > _Ax=std::allocator
    > ]


    Not sure what this means. A guess is that there is some compiler extension
    that classes must be _declspec(dllexport) or something like that to be used
    in header files of DLLs. See if the pointer to implementation idea works
    for you.

    // CTEngine.h
    #include guard
    class CTEngine
    {
    public:
    static CTEngine *LoadGraph( istream &i );
    CTEngine(const CTEngine&);
    CTEngine& operator=(const CTEngine&);
    ~CTEngine();
    private:
    struct Imp;
    Imp * imp;
    CTEngine();
    };

    // CTEngine.cpp
    #include "CTEngine.h"
    #include
    struct CTEngine::Imp
    {
    list GraphList;
    };
    CTEngine::CTEngine() : d_imp(NULL)
    {
    d_imp = new Imp();
    }
    CTEngine::~CTEngine()
    {
    delete d_imp;
    }
    CTEngine::CTEngine(const CTEngine& that) : d_imp(new Imp(*that.d_imp))
    {
    }
    CTEngine& CTEngine:perator=(const CTEngine& that);



  4. Re: DLL's with STL problem


    "Siemel Naran" wrote in message
    news:TDXdc.9398$i74.182140@bgtnsc04-news.ops.worldnet.att.net...
    > "Spacen Jasset" wrote in message
    >
    > > I am trying to put some classes in a DLL and use the STL libraries too,

    > the
    > > list class inpaticular is giving trouble, thus:
    > >
    > > class __declspec( dllexport ) CTEngine;
    > >
    > > class CTEngine
    > > {
    > > public:
    > > static CTEngine *LoadGraph( istream &i );
    > > private:
    > > list GraphList;
    > > CTEngine();
    > > };
    > >
    > > ct.h(20) : warning C4251: 'CTEngine::GraphList' : class

    > 'std::list<_Ty,_Ax>'
    > > needs to have dll-interface to be used by clients of class 'CTEngine'
    > > with
    > > [
    > > _Ty=CTNode *,
    > > _Ax=std::allocator
    > > ]

    >
    > Not sure what this means. A guess is that there is some compiler

    extension
    > that classes must be _declspec(dllexport) or something like that to be

    used
    > in header files of DLLs. See if the pointer to implementation idea works
    > for you.
    >
    > // CTEngine.h
    > #include guard
    > class CTEngine
    > {
    > public:
    > static CTEngine *LoadGraph( istream &i );
    > CTEngine(const CTEngine&);
    > CTEngine& operator=(const CTEngine&);
    > ~CTEngine();
    > private:
    > struct Imp;
    > Imp * imp;
    > CTEngine();
    > };
    >
    > // CTEngine.cpp
    > #include "CTEngine.h"
    > #include
    > struct CTEngine::Imp
    > {
    > list GraphList;
    > };
    > CTEngine::CTEngine() : d_imp(NULL)
    > {
    > d_imp = new Imp();
    > }
    > CTEngine::~CTEngine()
    > {
    > delete d_imp;
    > }
    > CTEngine::CTEngine(const CTEngine& that) : d_imp(new Imp(*that.d_imp))
    > {
    > }
    > CTEngine& CTEngine:perator=(const CTEngine& that);
    >
    >


    I see. Hide the details from the compiler. I suspect that might work I will
    have to try it. I am after a genral approach beucase I want to be able to
    port the bulk of the code. What you suggest seems like a good idea but it I
    imagine it could get messy.



+ Reply to Thread