[thread] Including boost/thread/mutex.hpp breaks .NET applications
Is the following problem already known? 1) Create a new C++/CLI project in Visual Studio 2005 (eg. a console application). 2) Include the header <boost/thread/mutex.hpp>. That's all. When you build and run the application you see the following Windows error message: "The application failed to initialize properly (0xc000007b). Click on OK to terminate the application." If you build a .NET DLL and try to use it from another .NET application the error message changes to: "is not a valid Win32 application. (Exception from HRESULT: 0x800700C1)" In both cases Windows refuses to load the file. While you normally don't need Boost.Thread in a .NET application I ran into this problem because we have a thin .NET layer on top of a native C++ code DLL. As the DLL makes heavy use of various Boost libraries the header <boost/thread/mutex.hpp> ends up in the .NET DLL. Does anyone have an idea why including this header is a problem? Boris
Boris wrote:
Is the following problem already known?
1) Create a new C++/CLI project in Visual Studio 2005 (eg. a console application). 2) Include the header <boost/thread/mutex.hpp>.
That's all. When you build and run the application you see the following Windows error message:
"The application failed to initialize properly (0xc000007b). Click on OK to terminate the application."
Does this also happen with the DLL version of Boost.Threads? The static library implements thread-local storage cleanup in a way that VS2005 does not support (and MS apparently has no plans to fix that.)
On Tue, 11 Sep 2007 16:40:25 +0300, Peter Dimov <pdimov@pdimov.com> wrote:
Boris wrote:
Is the following problem already known?
1) Create a new C++/CLI project in Visual Studio 2005 (eg. a console application). 2) Include the header <boost/thread/mutex.hpp>.
That's all. When you build and run the application you see the following Windows error message:
"The application failed to initialize properly (0xc000007b). Click on OK to terminate the application."
Does this also happen with the DLL version of Boost.Threads?
The static library implements thread-local storage cleanup in a way that VS2005 does not support (and MS apparently has no plans to fix that.)
I've been defining BOOST_THREAD_USE_DLL in the .NET project now. That seems to work. The C++ DLL still binds to Boost.Thread statically (and doesn't define BOOST_THREAD_USE_DLL of course). As the .NET DLL doesn't use Boost.Thread itself I guess it should be fine to define BOOST_THREAD_USE_DLL. Boris
participants (2)
-
Boris
-
Peter Dimov