Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linker Error: LNK2022

I am trying to use boost threads in a project having common language runtime support. I get the following linker error. error LNK2022: metadata operation failed (8013119F) : A TypeRef exists which should, but does not, have a corresponding TypeDef: (dummy): (0x01000073).

If i comment the line instantiating the boost thread, i do not get any linker error.

I tried looking online for fixing this error, at one such place it was suggested to use " #define BOOST_THREAD_USE_DLL" before including any boost libraries. I tried this but it still gives me the same error.

There is a related thread, ( "LNK2022: metadata operation failed" driving me insane ) but it isnt the same problem but somewhat similar. I tried the fix suggested there but still no luck.

Does anyone know how to fix this?

like image 711
Aaron Berry Avatar asked Dec 18 '25 00:12

Aaron Berry


2 Answers

# include <boost/thread.hpp>
namespace boost {
    struct thread::dummy {};
}

This helped me

like image 190
Dmitriy Avatar answered Dec 19 '25 14:12

Dmitriy


In my case, similar error occurred when using OpenCV 4.1.1. VS2019 is OK, but VS2015 is not good. Error message is like this.

LNK2022: metadata operation failed (8013119F) : A TypeRef exists which should, but does not, have a corresponding TypeDef: (Impl): (0x0100002a)

I searched struct or class named "Impl" in OpenCV include files. Then I could avoid the error adding the follow codes just under #include opencv headers.

namespace cv {
    namespace cuda {
        class Stream::Impl {};
    }
}
namespace cv {
    namespace cuda {
        class Event::Impl {};
    }
}

Answers in here were very helpful for me. Thank you.

like image 29
Tollow Avatar answered Dec 19 '25 14:12

Tollow



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!