Click here to Skip to main content
15,901,505 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hello,
I have two c++ lib file which I want to link in my Managed c++ application. While liking it gives 56 link error and I am able to figure out how to resolve these errors. Here are few error details:

Quote:
error LNK2005: "private: static class std::locale::_Locimp * __cdecl std::locale::_Getgloballocale(void)" (?_Getgloballocale@locale@std@@CAPAV_Locimp@12@XZ) already defined in msvcprtd.lib(MSVCP110D.dll)

error LNK2005: "public: __thiscall std::exception::exception(class std::exception const &)" (??0exception@std@@QAE@ABV01@@Z) already defined in MSVCRTD.lib(MSVCR110D.dll)

error LNK2005: __calloc_dbg already defined in MSVCRTD.lib(MSVCR110D.dll)

error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MTd_StaticDebug' doesn't match value 'MDd_DynamicDebug' in ManagedWrapper.obj


Please let me know if anybody know how to solve this problem.

What I have tried:

I ignored LIBCMTD.lib and MSVCRTD.lib from Properties->Linker->Input in CLR project but still giving link error.

I changed runtime library to "Multi-threaded Debug (/MTd)" in Properties->c/C++->Code_Generation for CLR project but I get error "'/clr' and '/MTd' command-line options are incompatible"
Posted
Updated 29-Mar-16 3:36am
Comments
Sergey Alexandrovich Kryukov 29-Mar-16 9:30am    
There is no such thing as "Managed C++", for a long time now. It has been superseded by C++/CLI. Is it what you are using? :-)
And the section "What I have tried" is designed to show us what you really tried, not just for mentioning it. How about a comprehensive code sample?
—SA

1 solution

Please see my comment to the question.

C++ is unique language in this respect. You can use regular P/Invoke .NET API, but it's really beneficial to use mixed-mode projects where you can freely mix managed + unmanaged. Please see:
Calling Native Functions from Managed Code[^],
Using C++ Interop (Implicit PInvoke)[^],
Using Explicit PInvoke in C++ (DllImport Attribute)[^],
Native and .NET Interoperability[^].

—SA
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900