Boost::Thread referenced to a MFC regular dll, assertion error occur while loading this dll
Hello everyone! I created a new VC2008 MFC regular dll project, do nothing but insert a line in stdafx.h: #include <boost/thread.hpp> Then I exported a do-nothing function at the dll's head file: extern "C" __declspec(dllexport) void DllFunc() { } After I compiled the proejct, I got a dll file and a lib file. I created a MFC dialog project, implicit call to the dll, that's: 1) #include the dll's head file 2) use #pragma comment(lib, "...") to import the dll's lib file 3) make a call to the DllFunc in dll I run the dialog project in the debug mode, and got an assertion error: void AFXAPI AfxCoreInitModule() { ASSERT(AfxGetModuleState() != AfxGetAppModuleState()); // assertion error // the return value of AfxGetModuleState() and AfxGetAppModuleState() are both not-empty, // but they are not the same. ... } Could anybody help me? thanks! My boost version is 1.38, 1.42 also tried. Compiler: Microsoft VC2008 (SP1)
You can't call (some) MFC functions from a thread that wasn't started with AfxBeginThread, which boost::thread doesn't use. Generally, anything in MFC that requires access to thread-local-storage (Like AfxGetMainWnd(), etc) will be broken.
Thanks for your response, but I do not use any boost:thread functions but just included it's head file... Are there any solutions ? thanks a lot! 2010/4/15 Eric J. Holtman <eric@holtmans.com>:
You can't call (some) MFC functions from a thread that wasn't started with AfxBeginThread, which boost::thread doesn't use.
Generally, anything in MFC that requires access to thread-local-storage (Like AfxGetMainWnd(), etc) will be broken.
_______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
participants (2)
-
DDGG
-
Eric J. Holtman