Are user attributes incompatible?

I converted the C ++ library to a managed system and received the following error in this line of code:

std::ifstream fin(filename, std::ifstream::in); 

Errors:

 Error 30 error LNK2022: metadata operation failed (80131195) : Custom attributes are not consistent: (0x0c0003b5). C:\Users\Freeman\Documents\Visual Studio 2010\Projects\testsharp1\cpp1\MSVCMRTD.lib(locale0_implib.obj) Error 32 error LNK2034: metadata inconsistent with COFF symbol table: symbol ' ??0_Container_base12@std @@ $$FQAE@XZ ' (06000493) has inconsistent metadata with (0A000075) in MSVCMRTD.lib(locale0_implib.obj) C:\Users\Freeman\Documents\Visual Studio 2010\Projects\testsharp1\cpp1\LINK Error 59 error LNK2034: metadata inconsistent with COFF symbol table: symbol ' ?memcpy@ @ $$J0YAPAXPAXPBXI@Z ' (060004DD) has inconsistent metadata with (0A0003E3) in MSVCMRTD.lib(locale0_implib.obj) C:\Users\Freeman\Documents\Visual Studio 2010\Projects\testsharp1\cpp1\LINK Error 60 error LNK1255: link failed because of metadata errors C:\Users\Freeman\Documents\Visual Studio 2010\Projects\testsharp1\cpp1\LINK 

How to fix this or how to change this line of code without changing the rest of the code?

+4
source share
2 answers

Essentially, you are compiling managed code that includes a <fstream> header. This means that all ads from <fstream> compiled as if they were being managed. However, the CRT DLL contains unmanaged versions of <fstream> .

At link time, this is detected when import lib MSVCMRTD.lib contains the unmanaged class std::_Container_base , but your .obj files require a managed std::_Container_base .

( _C tells us its helper implementation class).

+1
source

I know this question is out of date, but after 1 week of dealing with it, I feel obligated to publish the solution that I found, to someone with whom you can deal with such a mistake.

In my case, I had two projects: one unmanaged with std all over the place (list, vectors and queues, this is a project that should work on linux too, so I can’t use the .net collection) and pure standard C ++ code, in the second project, I create a managed project to wrap these classes that will be used in .net projects, I used Visual Studio 2010, trying to use framework 2.0, unfortunately, VS 2010 does not have good support for VC ++, and I tried everything, to get it to use 2.0, without success, every time I compile shaft, I got the same annoying message "Invincible blah".

I installed VS 2008, ported projects for 2008 and voila! everything worked in 10 minutes, I spend 1 week trying to solve this problem in VS 2010 and 2008, did the trick.

Hope this saves you many hours trying to solve something that seems insoluble on VS 2010.

+1
source

All Articles