- Published on
MFC DLL: Debug Assertion Failed `dllinit.ccp` Line 587
- Authors

- Name
- Daisuke Kobayashi
- https://twitter.com
I ran into the error above while building a DLL that uses MFC. It launched in release mode, but AFX_MANAGED_STATE(AfxGetStaticModuleState) did not behave correctly, and loading failed in the Serialize section.
The cause was that I had linked Boost.Thread statically.
The fix was to link the Boost.Thread library dynamically. Defining the macro below solved the problem.
#define BOOST_THREAD_DYN_LINK
Reference
http://stackoverflow.com/questions/5355931/adding-include-boost-thread-mutex-hpp-breaks-my-activex-control
http://article.gmane.org/gmane.comp.lib.boost.user/22617/match=clr
Added on 2013/12/03
It seems Boost also includes a header that avoids this conflict. Including the header below in the MFC application's main source file also worked around the issue.
#include <boost/thread/win32/mfc_thread_init.hpp>