When I compile a mex with the -g (debug mode) option in Windows, Visual Studio is passed the flag /MD (at least in Matlab 2013b/2015a), which selects the release-mode C and C++ standard libraries.
When building in debug-mode outside of Matlab, the default (e.g. in CMake) is to use /MDd and /D_DEBUG, which selects the debug-mode C and C++ standard libraries. When such a library is linked to in Matlab, Visual Studio emits the LNK4098 conflicting library warning.
The warning — which should be fixed — can be fixed by changing either Matlab's build flags, or the library's build flags.
Why doesn't Matlab use /MDd in debug-mode, to select the debug-mode standard libraries?