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 -fopenmp
flag to tell the compiler you want to use openmp, your example compiles fine as g++ test.cpp -fopenmp -o test
on mac osx lion
It is hard to diagnose such a problem. I guess the linker cannot find the library. Add libgomp to you linker libraries.
You have to link library, to get object.
Simular problem here:
http://www.eclipse.org/forums/index.php/m/901477/
and more more over the internet. Reason is not linked library.
you can do it by adding: -fopenmp
in GCC.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With