Debug-mode compilation in Windows uses release-mode C and C++ standard libraries
1 次查看(过去 30 天)
显示 更早的评论
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?
0 个评论
回答(1 个)
Philip Borghesani
2015-6-4
Mex files have always been built and linked against release versions of the libraries to avoid conflicts caused by mixing release and debug versions of the libraries. To safely use the debug libraries all components that transfer ownership of objects or pass c++ objects must be linked with the same library. Supporting debug libraries could require shipping many components of Matlab and third party components with debug and release builds.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Call C++ from MATLAB 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!