10

Using Visual Studio 2008 and Boost Libraries 1.46.1 I want to compile and link the following with the /CLR flag:

#include <boost/thread/thread.hpp>
void run() {}
int main(int argc, char *argv[])
{
    boost::thread t(run);   
}

The first error is about a forward-declared dummy-struct in boost::thread. This post works around this by declaring:

namespace boost {
    struct thread::dummy {};
}

Sure, I now can compile, but then I get the linker warning

Warning 1 warning LNK4248: unresolved typeref token (0100001F) for 'boost.detail.win32._SECURITY_ATTRIBUTES'; image may not run

Running the application results in

The application was unable to start correctly (0xc000007b).

None of the suggestions in the previously mentioned forum thread works for me. I have built a static version of the Boost Threads lib, and it runs fine without the /CLR flag. Debug/Release makes no difference. I'm running under Win7 32-bit.

Any hints?

ildjarn
  • 62,044
  • 9
  • 127
  • 211
anve
  • 183
  • 1
  • 11
  • 1
    possible duplicate of [boost mutex C++/CLI problems](http://stackoverflow.com/q/5670248/636019) – ildjarn May 24 '11 at 00:25
  • @ildjarn: how is that? This is a linker error. The linked thread is a runtime error. – Matt Chambers Jun 05 '11 at 17:31
  • @Matt : "*The application was unable to start correctly (0xc000007b).*" sounds like a runtime error to me. – ildjarn Jun 05 '11 at 19:57
  • 1
    @ildjarn: You're right. Who needs reading comprehension anyway? I think they are duplicates and the linker warning is a red herring. – Matt Chambers Jun 06 '11 at 16:28
  • Have you tried using boost in a DLL? I remember something about non-clr in a static lib linked to a clr exe not being possible... – LiMuBei Nov 14 '11 at 13:18

1 Answers1

3

I've already run into this problem, i don't remember where i got this but one workaround is declare "boost.detail.win32._SECURITY_ATTRIBUTES" after including all the boost headers like so.

namespace boost { 
    namespace detail { 
        namespace win32 { 
            struct _SECURITY_ATTRIBUTES: public ::_SECURITY_ATTRIBUTES {}; 
        };
    };
}; 

Remove the namespaces if you want everyone to see it.

namar0x0309
  • 2,239
  • 1
  • 15
  • 15