When I try to compile the following program with runtime library Multithreaded Debug (/MTd).
#include <thread> #include <iostream> int main() { auto a = std::this_thread::get_id(); std::cout << "a"; }
I get the following errors.
1>libcpmt.lib(ppltasks.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>libcpmt.lib(ppltasks.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MTd_StaticDebug' in Source.obj
1>libcpmt.lib(excptptr.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>libcpmt.lib(excptptr.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MTd_StaticDebug' in Source.obj
1>libcpmt.lib(thread0.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in Source.obj
1>libcpmt.lib(thread0.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MTd_StaticDebug' in Source.obj
1>c:\...\Projects\Project2\Debug\Project2.exe : fatal error LNK1319: 6 mismatches detected
I use:
- Visual Studio 2015 (Version 14.0.25431.01 Update 3)
- Intel Parallel Studio 2018 Update 4 (2018.5.274)
- Microsoft Windows 10 Pro
- Appart from the runtime library I use the default values from an empty Visual Studio C++ Project.
I cannot possibly understand what the problem could be. Is there something wrong with me, or is there a bug in the compiler or somewhere else?
The error goes away if I remove the second line std::cout... It also goes away if I use printf('..') instead, so it seems to be an issue with the combination of thread and iostream.
I'm able to solve the problem by ignoring that specific library (/NODEFAULTLIB:"libcpmt.lib"), but I would rather like to find the real cause of the problem.
Does anyone have any idea what it could be?