issue about include boost thread header in MFC dll

I have a MFC dll application. I try to use Boost thread in the dll. #include "stdafx.h" #include "interface.h" #include "MFCDLL.h" #include <boost/thread.hpp> // The one and only CMFCDLLApp object CMFCDLLApp theApp; EXPORT32 int __stdcall func() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); ... return DLL_OK; } The build is OK. But when I call the func, it crashes. If I comment the line: //#include <boost/thread.hpp> Then it works well. So how to use thread in MFC dll? -- View this message in context: http://boost.2283326.n4.nabble.com/issue-about-include-boost-thread-header-i... Sent from the Boost - Users mailing list archive at Nabble.com.

I have a MFC dll application. I try to use Boost thread in the dll.
#include "stdafx.h" #include "interface.h" #include "MFCDLL.h"
#include<boost/thread.hpp>
// The one and only CMFCDLLApp object CMFCDLLApp theApp;
EXPORT32 int __stdcall func() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); ... return DLL_OK; }
The build is OK. But when I call the func, it crashes. If I comment the line: //#include<boost/thread.hpp>
Then it works well. So how to use thread in MFC dll? Providing exact errors here would be more helpful in reasoning about the
On 06/22/2012 07:45 AM, young wrote: problem. Anyway, Most common cause of this problem could be that you are not linking your program with boost thread library ( i.e. libboost_thread-mt.a). It could result in errors saying "Undefined Symbols". If you have indeed linked boost thread library with your program then another reason for errors could be that you have used different link flags. I mean that you may have missed "/MT" flag while compiling your program.
-- View this message in context: http://boost.2283326.n4.nabble.com/issue-about-include-boost-thread-header-i... Sent from the Boost - Users mailing list archive at Nabble.com. _______________________________________________ Boost-users mailing list Boost-users@lists.boost.org http://lists.boost.org/mailman/listinfo.cgi/boost-users
DISCLAIMER: ----------------------------------------------------------------------------------------------------------------------- The contents of this e-mail and any attachment(s) are confidential and intended for the named recipient(s) only. It shall not attach any liability on the originator or NECHCL or its affiliates. Any views or opinions presented in this email are solely those of the author and may not necessarily reflect the opinions of NECHCL or its affiliates. Any form of reproduction, dissemination, copying, disclosure, modification, distribution and / or publication of this message without the prior written consent of the author of this e-mail is strictly prohibited. If you have received this email in error please delete it and notify the sender immediately. . -----------------------------------------------------------------------------------------------------------------------

Le 22/06/12 04:15, young a écrit :
I have a MFC dll application. I try to use Boost thread in the dll.
#include "stdafx.h" #include "interface.h" #include "MFCDLL.h"
#include<boost/thread.hpp>
// The one and only CMFCDLLApp object CMFCDLLApp theApp;
EXPORT32 int __stdcall func() { AFX_MANAGE_STATE(AfxGetStaticModuleState()); ... return DLL_OK; }
The build is OK. But when I call the func, it crashes. If I comment the line: //#include<boost/thread.hpp>
Then it works well. So how to use thread in MFC dll?
Hi, which version of Boost are you using? How it crashes? Have you access to a readable stack? Could you add the compiler command lines? Could you provide a complete example? And last, could you create a track ticket with all these informations? Best, Vicente

I put the all dll source code here: MFCDLL.def - ======== LIBRARY MFCDLL EXPORTS ShowDialog interface.h ======= #ifndef INTERFACE_H_INCLUDED #define INTERFACE_H_INCLUDED #if defined DAS_DLL #define EXPORT32 __declspec(dllexport) #else #define EXPORT32 __declspec(dllimport) #endif #define DLL_OK 0 #define DLL_ERROR -1 extern "C" EXPORT32 int __stdcall ShowDialog(HWND hwndParentWindow); #endif interface.cpp ========= #include "stdafx.h" #include "interface.h" #include "MFCDLL.h" #include <boost/thread.hpp> CMFCDLLApp theApp; EXPORT32 int __stdcall ShowDialog(HWND hwndParentWindow) { AFX_MANAGE_STATE(AfxGetStaticModuleState()); return DLL_OK; } MFCDLL.h ======= #pragma once #ifndef __AFXWIN_H__ #error "include 'stdafx.h' before including this file for PCH" #endif #include "resource.h" // main symbols class CMFCDLLApp : public CWinApp { public: CMFCDLLApp(); public: virtual BOOL InitInstance(); virtual int ExitInstance( ); DECLARE_MESSAGE_MAP() }; MFCDLL.cpp ======== #include "stdafx.h" #include "MFCDLL.h" #ifdef _DEBUG #define new DEBUG_NEW #endif BEGIN_MESSAGE_MAP(CMFCDLLApp, CWinApp) END_MESSAGE_MAP() CMFCDLLApp::CMFCDLLApp() { } BOOL CMFCDLLApp::InitInstance() { CWinApp::InitInstance(); return TRUE; } int CMFCDLLApp::ExitInstance() { return CWinApp::ExitInstance(); } and error message: http://boost.2283326.n4.nabble.com/file/n4631691/err.png err.png -- View this message in context: http://boost.2283326.n4.nabble.com/issue-about-include-boost-thread-header-i... Sent from the Boost - Users mailing list archive at Nabble.com.

I forgot to mention that I am using Visual Studio 2010 and Boost library 1.49. -- View this message in context: http://boost.2283326.n4.nabble.com/issue-about-include-boost-thread-header-i... Sent from the Boost - Users mailing list archive at Nabble.com.

It looks like I can not link to the static thread library. If I changed to dynamic thread library, it seems works. Can anyone confirm that? -- View this message in context: http://boost.2283326.n4.nabble.com/issue-about-include-boost-thread-header-i... Sent from the Boost - Users mailing list archive at Nabble.com.
participants (3)
-
Pravar
-
Vicente J. Botet Escriba
-
young