Published on

MFC DLL - Debug Assertion Failed dllinit.ccp Line 587

Authors

MFC を使用した,DLL の作成中に上記のエラーが発生.Release モードでは起動できたのですが,AFX_MANAGED_STATE(AfxGetStaticModuleState) がうまくいかず Serialize の部分でのロードに失敗していました.

原因は Boost.Thread をスタティックリンクしていたことでした.

解決方法としては,Boost.Thread ライブラリを動的リンクすればよいとのこと.下記マクロを定義することで解決しました.

#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

2013/12/03 追記

この衝突を回避するヘッダーが Boost に入っているようです.以下のヘッダ-を MFC の main で include したら回避出来ました.

#include <boost/thread/win32/mfc_thread_init.hpp>