Q:

Export a STL class member containing the same class in a DLL interface

Say I have a class that references itself in a STL container:
class __declspec(dllexport) Widget {
protected:
    std::vector<Widget *> children;
}

If I have say a vector of int instead, before the class definition I can have the following:
template class __declspec(dllexport) std::vector<int>;

Which supposedly will work. But how to I do that if the class isn't defined yet? Forward declaring the class:
class Widget;
template class __declspec(dllexport) std::vector<Widget *>;

Doesn't get rid of the warning I get from MSVC which is;
warning C4251: 'Widget::children' : class 'std::vector<Widget *,std::allocator<_Ty>>' needs to have dll-interface to be used by clients of class 'Widget'
I believe the information in the warning itself is somehow relevant but I'm not sure exactly how to proceed.

A:

Taken from here, the family of these errors are essentially noise;

C4251 is essentially noise and can be silenced
  - Stephan T. Lavavej (one of the maintainer's of Micrsoft's C++ library).

So long as the compiler options are consistent through the project, just silencing this warning should be just fine.
As a more comprehensive alternative you can look at the pimpl pattern and remove the std::vector from the class definition and thus it would not need to be exported from the dll.
class __declspec(dllexport) Widget {
protected:
    struct Pimpl;
    Pimpl* pimpl_;
}

// in the cpp compiled into the dll
struct Widget::Pimpl {
    // ...
    std::vector<Widget*> children;
    // ...
}

MSDN has a nice article on this as part of an introduction to newer C++11 features.
In general, it is easier to not use std classes in a dll interface, especially if interoperability is required.

