Hi all.
I'm trying to link the microsoft (VS2013) port for the caffe deep learning framework against MKL instead of the default OpenBlas library. MKL support with preprocessor-switched includes is already built-in, so I hoped to only link against the correct files (as indicated by MKL Link Line Advisor) and be done. Partially, it works.
The solution structure is as follows:
The static lib libcaffe is used by a caffe executable project (compiles, links and runs correctly using both OpenBlas and MKL). Additionally, there is my custom DLL that acts as a wrapper for libcaffe. It compiles, links and runs correctly using OpenBlas.
However, when I try to link against MKL, I get lots of linker errors LNK2038 reporting a conflict between MT_StaticRelease and MD_DynamicRelease (in one of my object files). In debug mode, I get many additional linker errors of the type
libcpmt.lib(xlocale.obj) : error LNK2005: "public: __thiscall std::locale::id::id(unsigned int)" (??0id@locale@std@@QAE@I@Z) is already defined in msvcprtd.lib(MSVCP120D.dll)
From what I read here https://msdn.microsoft.com/en-us/library/jj889284(v=vs.120).aspx this error is due to a library (in this case, MKL) and my DLL project using different run time libraries. This error persists regardless of whether I try to link against MKL statically (which Is what I would prefer so I don't have to ship several very large DLLs, i.e. link against mkl_intel_c.lib;mkl_core.lib;mkl_sequential.lib;) or dynamically (link against mkl_intel_c_dll.lib;mkl_core_dll.lib;mkl_sequential_dll.lib). I tried setting all required projects to link against the MT_StaticRelease runtime, but this also produces errors, because a different required library insists on the MD_Dynamic runtime switch.
Linking does work when I link against mkl_rt.lib.
Is this behavior intentional? How can I work around this if I want to link statically?
Thanks and greetings,
Daniel