c++ fatal error C1189: #error:解决方案

fatal error C1189:

错误类型:(atl)

1、C:Program Files (x86)Microsoft Visual Studio 14.0VCincludemutex(8): fatal error C1189: #error: <mutex> is not supported when compiling with /clr or /clr:pure.

2、C:Program Files (x86)Microsoft Visual Studio 14.0VCinclude hread(8):fatal error C1189: #error: <thread> is not supported when compiling with /clr or /clr:pure.

方案1

参考博客:

方案2:修改源码:

修改C:Program Files (x86)Microsoft Visual Studio 14.0VCincludemutex 文件:

#ifndef RC_INVOKED

#ifdef _M_CEE
#ifndef _CLR_NATIVE_THREADS  //添加运行时原生线程
#error <mutex> is not supported when compiling with /clr or /clr:pure.
#endif /* _CLR_NATIVE_THREADS */
#endif /* _M_CEE */

添加#ifndef _CLR_NATIVE_THREADS #endif

同理修改thread文件

 LNK1104: cannot open file MSCOREE.lib

解决方案:

如果出现这个链接错误,请添加library directories: C:Program Files (x86)Microsoft SDKsWindowsv7.0ALib (请根据自身电脑Microsoft SDKs文件位置添加)

或者修改如下(链接器处添加(主流方式))

写在最后:

经验分享 程序员 微信小程序 职场和发展