Reputation: 45
Does anyone know how to enable the use of OpenMP in Xcode 9.0?
In Xcode 8, I procide as described in this tutorial but it doesn't work anymore in Xcode 9.0 ...
The error is : clang-5.0: error: cannot specify -o when generating multiple output files
Thanks in advance for help
Upvotes: 3
Views: 994
Reputation: 5566
Xcode 11.7
There are 2 ways (no need to use both)
llvm
libomp
Follows libomp
:
Install libomp
brew install libomp
Write some code:
#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());
}
}
In build setting make following changes
-lomp
/usr/local/opt/libomp/include
/usr/local/opt/libomp/lib
-Xpreprocessor AND -fopenmp
Mission success:
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
Upvotes: 0
Reputation: 128
I think the problem is in flag -index-store-path In build settings > build options set Enable Index-While-Building Functionality to No
Upvotes: 5