Community
cancel
Showing results for 
Search instead for 
Did you mean: 
Geir_Berge
Beginner
568 Views

Linker error using std::thread with /MTd

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?

0 Kudos
9 Replies
Viet_H_Intel
Moderator
568 Views

 

I wonder if it compiles with MS compiler?

Thanks,

Viet

Eirik_Marthinsen
Beginner
568 Views

(I'm a colleague of Geir)

Yes, it does compile with with MSVC.

I have now tested it from the commandline with the single source file.

$ icl main.cpp  # This is ok
$ icl main.cpp /MTd /link /NODEFAULTLIB:libcpmt.lib # This is ok
$ icl main.cpp /MTd # This causes the error

Using cl (MSVC) instead of icl is no problem.

Is it possible to reproduce or is it a problem just on my system?

Geir_Berge
Beginner
568 Views

It compiles fine with MSVC.

I have now tested the single source file from the command line:

> icl main.cpp  # This is ok
> icl main.cpp /MTd /link /NODEFAULTLIB:libcpmt.lib  # This is ok
> cl  main.cpp /MTd  # This is ok (using cl (MSVC))
> icl main.cpp /MTd  # This gives the link errors described in the first post.

So is this reproducible? Or is it something wrong on my system?

Viet_H_Intel
Moderator
568 Views

 

I am able to reproduce it and submitted this issue to our developer and will keep you updated. Internal tracker is CMPLRLIBS-2727. 

Thanks,

Viet

Eirik_Marthinsen
Beginner
568 Views

Thanks for looking into it, Viet.

Good to know it's not our fault. :)

tony_
Beginner
568 Views

Hello, I was wondering if this issue has been resolved? I'm seeing something similar in a VS2017 project (with Intel Parallel Studio 2018 update 3 for Fortran).

The C++ project's runtime library setting is /MTd (Multi-threaded Debug)

Below are the link errors; 

libcpmt.lib(ppltasks.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in COMMap1D.obj
1>libcpmt.lib(ppltasks.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MTd_StaticDebug' in COMMap1D.obj
1>libcpmt.lib(excptptr.obj) : error LNK2038: mismatch detected for '_ITERATOR_DEBUG_LEVEL': value '0' doesn't match value '2' in COMMap1D.obj
1>libcpmt.lib(excptptr.obj) : error LNK2038: mismatch detected for 'RuntimeLibrary': value 'MT_StaticRelease' doesn't match value 'MTd_StaticDebug' in COMMap1D.obj

Thank you for any assistance.

Tony

Viet_H_Intel
Moderator
568 Views

As far as I know, it hasn't been fixed in the latest released compiler.

Boni__Francisco
Beginner
568 Views

I can reproduce this and I confirmed it hasn't been fixed in the latest version (ICC 19.0 Update 4)

Boni__Francisco
Beginner
568 Views

I really hope some dev can take a look into this. It still happening in ICC 19.1 Technical Preview (package 085) and ICC 19.0.5.

 

With both MSVC 2019 16.4 preview 1 (VC++ 14.24.28117) and the stable MSVC 2019 16.3.1 (VC++ 14.22) [Windows SDK 10.0.18362.0]

Reply