I'm trying to use openMP in C with Xcode 11.4. I have installed libomp with Homebrew, and homebrew apparently installed it in: /usr/local/Cellar/libomp/10.0.0/
The code below generates a linker error: Undefined symbol: _omp_get_max_threads (likewise for get_thread_num).
#include <stdio.h>
#include "/usr/local/Cellar/libomp/10.0.0/include/omp.h"
int main () {
#pragma omp parallel
{
int threadNum = omp_get_thread_num ();
int maxThreads = omp_get_max_threads();
}
return 0; }
I tried adding usr/local/Cellar to the Header Search Paths, and including omp.h directly in my Xcode project, and adding compilation flag -openmp
, behavior does not change.
1) I coulnd't find a way to install OpenMP through Xcode directly, would it be possible / preferable?
2) Do I need to do something further for Xcode to recognize a library installed with Homebrew?
3) Why did Homebrew install the library in usr/local/Cellar, is that a bad sign?
4) Why is the missing symbol _omp_get_max_threads
and not omp_get_max_threads
?
(edit): There is also under usr/local/include the same three headers, omp.h, ompt.h and omp-tools.h, as in /usr/local/Cellar/libomp/10.0.0/. Not sure why.