有谁知道如何在Xcode 9.0中启用OpenMP?
在Xcode 8中,我按照this tutorial中的说明进行操作,但它在Xcode 9.0中不再起作用了......
错误是:clang-5.0: error: cannot specify -o when generating multiple output files
提前感谢您的帮助
答案 0 :(得分:4)
我认为问题出在flag -index-store-path中 在构建设置中>构建选项集启用索引 - 构建时功能为否
答案 1 :(得分:0)
Xcode 11.7
有2种方法(无需同时使用)
llvm
libomp
遵循libomp
:
安装libomp
brew install libomp
编写一些代码:
#include <omp.h>
- (void)applicationDidFinishLaunching:(NSNotification *)aNotification {
#pragma omp parallel num_threads(4)
{
printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());
}
}
在构建设置中进行以下更改
-lomp
/usr/local/opt/libomp/include
/usr/local/opt/libomp/lib
-Xpreprocessor AND -fopenmp
任务成功:
2020-09-30 17:23:58.449045+0800 QRGenerator2[24352:3549441] Metal API Validation Enabled
Hello from thread 0, nthreads 4
Hello from thread 1, nthreads 4
Hello from thread 3, nthreads 4
Hello from thread 2, nthreads 4