I cannot find this question anywhere on the internet.
So my linker error is: Undefined symbols for architecture x86_64: “_omp_get_thread_num()”
This is my code:
int nthreads;
int tid;
#pragma omp parallel private(tid)
{
tid = omp_get_thread_num();
if (tid == 0)
{
nthreads = omp_get_num_threads();
printf("number of threads: %d\n", nthreads);
}
}
Looks you forgot to use the
-fopenmpflag to tell the compiler you want to use openmp, your example compiles fine asg++ test.cpp -fopenmp -o teston mac osx lion