Getting error while compiling debug mode: C ++ / CLI - error LNK2022

I have CLI code that wraps a C ++ DLL.
When I try to compile it in debug mode, I get the following error:

Error 22 Error LNK2022: Metadata failure (8013118D):

Inconsistent information about layouts with propagated types. MSVCMRTD.lib (locale0_implib.obj)

The strange thing is that in Release mode it compiles and works fine.
The only difference that I see causes a problem when I change:

Configuration Properties -> C / C ++ -> Code Generation -> Runtime Library

When it is set to:, Multi-threaded Debug DLL (/MDd)it throws an error.
When it is set to:, Multi-threaded DLL (/MD)it compiles fine.

The same settings work for all other DLLs in the project (CLI and C ++), and they inherit the same properties.

I am using VS2010.

So how can I solve this?

And can I get an explanation WHY is this happening?

Update:

I basically tried to change every parameter in the project properties without any luck.

I read somewhere that this could be caused by duplicate type declarations with the same name.
But in the CLI file, I call std :: string, etc. Explicitly from std.

  • Renaming objects does not work.

Any other ideas?

Update:

Multiple copies of errors:

error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (std._String_val<char,std::allocator<char> >): (0x02000097).  E:\MyProject....\MSVCMRTD.lib(locale0_implib.obj)   DllName


error LNK2022: metadata operation failed (8013118D) : Inconsistent layout information in duplicated types (std._String_iterator<char,std::char_traits<char>,std::allocator<char> >): (0x02000091).  E:\MyProject....\MSVCMRTD.lib(locale0_implib.obj)   AnotherDllName

Please note that the MSVCMRTD.lib file is actually an MS file used for compilation, and is actually not my project (and should not be)

Update

If this helps you, run the linker command line:

/OUT: "E:\blah.CLI.dll" /INCREMENTAL /NOLOGO/LIBPATH: "e:\blah\Output \" /LIBPATH: "E:\\lib_64" /LIBPATH: "blah\Lib_64 \" /DLL "e:\Otheblaf.lib" / /ManifestFile: "x64\Debug\blah.CLI.dll.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC: " = 'asInvoker' uiAccess = 'false'" /DEBUG /PDB: "E:\blah.CLI.pdb" /SUBSYSTEM: WINDOWS/OPT: NOREF /OPT: NOICF/PGD: "E:\blah.CLI.pgd" /TLBID: 1/DYNAMICBASE: NO/FIXED: NO /MACHINE: X64/ERRORREPORT: QUEUE

, :

/OUT: "E:\blah.CLI.dll" /: /NOLOGO/LIBPATH: "E:\blah \" /LIBPATH: "E:\\Output \" /LIBPATH: "E:\blah\lib_64" /DLL "Configuration.lib" "kernel32.lib" "user32.lib" "gdi32.lib" "winspool.lib" "comdlg32.lib" "advapi32.lib" "shell32.lib" "ole32.lib" "oleaut32.lib" "uuid.lib" "odbc32.lib" "odbccp32.lib" "E:\blah.lib" / /ManifestFile: "blah.CLI.dll.intermediate.manifest" /ALLOWISOLATION /MANIFESTUAC: " = 'asInvoker' uiAccess = 'false'" /DEBUG /PDB: "E:\blah.CLI.pdb" /SUBSYSTEM: WINDOWS/OPT: REF/OPT: ICF /PGD: "E:\blah.CLI.pgd" /LTCG/TLBID: 1 /DYNAMICBASE/FIXED: NO/MACHINE: X64 /ERRORREPORT: Queue

+3
6

- :

, boost::lexical_cast<std:string>

.Net std::. ( std::string, ).

, , (std::string ), .
.

MSDN -

, , "" .NET.

++, buggy , .

, . ( /)
VS2010 .cpp /clr.

- ref.

lexical_cast<std::string> :

ostringstream os;
os << i;
return os.str();
+1

make ? .

[a] , pragma pack DLL , - Windows , . .. -Zp cl.exe
, .

http://msdn.microsoft.com/en-us/library/xh3e3fd0%28v=VS.71%29.aspx

[b] , , - standrd . , , . , , ( ) , .

, .

+2

, 64 . > C/++ > > > 16 (/Zp16)

0

.

-1

, WINVER, , , , . .

-1

Source: https://habr.com/ru/post/1788784/


All Articles