I have VisualStudio 2012 and I a trusted third party told me I have to add the /MT compile flag to one C# project, so I can use a library which is not necessarily installed on the target system.
I did not find where/how to set this flag in VS.
It is a setting that only applies to C or C++ projects. It selects the kind of C runtime library that will be used. There are two basic flavors, /MT vs /MD, multiplied by two for Debug and Release builds, /MTd and /MDd. With /MT, the runtime library will get linked into the EXE program itself. With /MD, the runtime library is in a DLL that can be shared by all modules in the process. /MD is very important when you partition your program into multiple modules, like an EXE and one or more DLLs.
A vendor will tell you to use /MT only when they supplied you with a static link library, a .lib file. And gave you only one flavor of it, in general a very questionable practice that you should not put up with since it gives you many less options to build a program that uses the library. Unstated, but very important, is that he also needs to tell you what version of Visual Studio to use.
The .lib file he gave you is not useable from C# at all. You'll have to link it to C or C++ code that uses the library. To interop with C#, you'd typically want to use C++/CLI to write wrapper classes that give you access to the library functions. But you can't do that, C++/CLI only supports building with /MD. All that's left is creating a DLL that exports the functions with a .def file. You have to use pinvoke in your C# code to call them.
Clearly there's a rather major communication failure. You need to follow up and talk to the vendor to get this straightened out. Pursue this aggressively, getting stuck with a wonky library can be an enormous pita for many years to come, increasingly getting worse as tooling evolves.
Collected from the Internet
Please contact [email protected] to delete if infringement.
Comments