Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
304 views
in Technique[技术] by (71.8m points)

c++ - Adding #include <boost/thread/mutex.hpp> breaks my ActiveX control?

Is there a known problem with the boost::mutex header when used inside an ActiveX control?
(Boost version v1.39)

If I create an MFC ActiveX Control project in Visual Studio 2008 called "DefaultOCXControl" then I can build it, the control registers itself as part of the build, and can be inserted into the ActiveX Test Container as you would expect. All good.

If I then just add this line:

#include <boost/thread/mutex.hpp>

at the top of my DefaultOCXControlCtrl.h file and rebuild: the registration step at the end of the build fails with:

Debug Assertion Failed!
Program: C:Windowssystem32 egsvr32.exe
File: f:ddvctoolsvc7libsshipatlmfcsrcmfcdllinit.cpp
Line: 587

The offending assertion looks like this:

void AFXAPI AfxCoreInitModule()
{
    ASSERT(AfxGetModuleState() != AfxGetAppModuleState());
    ...

Attempting to insert the control into the ActiveX Test Container now results in the same message. If I remove the line and rebuild then everything is fine - so it definitely seems to be something in that header file that causes the issue.

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Have you tried linking boost::thread dynamically (define BOOST_THREAD_DYN_LINK)?

I had this kind of problems when using boost::thread with a mixed C++/.NET project and linking just boost::thread dynamically was the solution (here a possible explanation: http://article.gmane.org/gmane.comp.lib.boost.user/22617/match=clr)


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...