Reputation: 145
I have enabled OpenMP using following settings on 10.7.2 OS (Xcode):
GCC_VERSION = 4.2
ENABLE_OPENMP_SUPPORT = YES
LD_OPENMP_FLAGS = -fopenmp
But when I call set num threads function (omp_set_num_threads(2)
) I get the following linker error :
Undefined symbols:
_gomp_thread_attr", referenced from:
_gomp_run_sched_chunk in libgomp.a(env.o)
Am I missing something obvious? Should I add any library to resolve the linker errors?
Code:
#include <omp.h>
void function() {
omp_set_num_threads(2);
}
int main() {
function();
return 0;
}
Upvotes: 1
Views: 1709
Reputation: 13932
Make sure you actually add OMP pragmas to your file - the error should go away once you do. If you just want to test without OMP pragmas (not recommended!), you'll have to add some hack like this (for Apple's gcc 4.2.1 only):
#include <pthread.h>
pthread_attr_t gomp_thread_attr;
Upvotes: 2