Boost logo

Boost Users :

Subject: [Boost-users] C4251 needs to have dll-interface
From: Christopher Pisz (cpisz_at_[hidden])
Date: 2011-09-28 11:54:59


This might be more of a windows question, but...

Everytime I use a boost template as part of a class interface that is exported
from a dll, I get this compiler warning.

For example I just cut and paste the TcpServer example from
boost::asio::ip::tcp into a test project dll.

I get:
warning
C3251: 'boost_enable_shared_from_this<T>::weak_this_':class 'boost::weak_ptr<T>
' needs to have a dll-interface to be used by clients of
class 'boost::enable_shared_from_this<T>'

It comes from the line:
class __declspec(dllexport) TcpConnection : public
boost::enable_shared_from_this<TcpConnection>
{
public:
      typedef boost::shared_ptr<TcpConnection> SmartPtr;
.
.
.
};

How do I solve these types of errors?

Currently, I just include the correspnding boost header in the client project
and igore the warnings, but I'd really like to get rid of them.

Should I be including the boost headers and library in the client project?
Doesn't the client project get what it needs from the dll, when the dll
includes the headers and library?


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