【问题标题】:MSB6006: “CL.exe” exited with code 2 when using openMPMSB6006:“CL.exe”在使用 openMP 时以代码 2 退出
【发布时间】:2019-07-17 06:26:11
【问题描述】:

我尝试在visual studio中运行一些openMP示例,但是当启用/openMP时程序无法运行,返回错误“MSB6006: “CL.exe” exited with code 2”。示例如下:

int main(int argc, char* argv[]) { 
  #pragma omp parallel { 
     printf("Hello World... from thread = %d\n", omp_get_thread_num()); 
  } 
  return 0;
} 

感谢您的帮助。

【问题讨论】:

  • 查看输出,而不是错误窗口。

标签: c++ visual-studio


【解决方案1】:

当您使用 openMP 时,不能使用“两阶段名称查找”选项。这在输出窗口中显示,您可以在其中看到此消息:

1>c1xx:错误 C2338:C++/CLI、C++/CX 或 OpenMP 不支持两阶段名称查找;使用 /Zc:twoPhase-

要解决这个问题,请转到“项目属性”->“C/C++”->“命令行”并在底部的“附加选项”中添加 /Zc:twoPhase-,然后按确定.这解决了我的问题。

【讨论】:

  • 确认这个错误对我有用。
  • 也确认它有帮助。它应该被接受为答案吗?
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2018-10-15
  • 2018-03-26
  • 2014-12-15
  • 2020-01-15
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多