Boost logo

Threads-Devel :

Subject: [Threads-devel] [thread] LNK2022 error in VisualStudio 2008 (VC9) C++/CLR code
From: Matt Schuckmann (matt_at_[hidden])
Date: 2009-11-03 11:45:54

I'm not fully sure if this is a Microsoft problem or a boost problem but
here goes.

I'm using boost 1.37.0, ( I haven't tested yet but I believe the problem
will exist with 1.40.0 too)
The code below compiles and links fine if the /clr switch is off but
gives a LNK2022 error if it is turned on. The project is a CLR/C++ Class
Library (i.e. .NET DLL)

Error I'm seeing is:
ClassLibrary_test.obj : error LNK2022: metadata operation failed
(8013119F) : A TypeRef exists which should, but does not, have a
corresponding TypeDef: (dummy): (0x0100001c).

And it appears that the problem has to do with "struct dummy;"
declaration on line 144 of boost/thread/detail/thread.hpp. Apparently
the CLR compiler can't deal with an empty undefined struct type even
thow I've told the compiler to treat all of it as unmanaged code.

Can anyone make any suggestions on how to fix this?

Matt Schuckmann

File ClassLibrary.h:
// ClassLibrary_test.h

#pragma once

namespace ClassLibrary_test {

#if defined(_MANAGED)
public ref class Class1
class Class1

File ClassLibrary.cpp
#include "ClassLibrary_test.h"

#pragma managed(push, off)
#include <boost/thread/recursive_mutex.hpp>
#include <boost/thread/condition.hpp>
#include <boost/thread/thread.hpp>
//#pragma managed(pop)
class MyTest
 boost::condition condition;
   boost::mutex mutex;

 void wait()
   boost::mutex::scoped_lock lock(mutex);

 void notify()

class MyThread
 MyThread( MyTest& tst )
   : t(tst)

  MyTest& t;
 void operator()()

#pragma managed(pop)

  MyTest t;
  MyThread thrd(t);
  boost::thread temp(thrd);



Threads-Devel list run by bdawes at, david.abrahams at, gregod at, cpdaniel at, john at