0
votes

So I'm trying to learn how to use openMP on a OSX Yosemite however stock gcc doesn't seem to support openMP so I installed gcc 4.9 from homebrew. The problem occurs when I try to compile the following code using this command: gcc-4.9 main.cpp -fopenmp -o program

#include <omp.h>
#include <stdio.h>
int main() {
   #pragma omp parallel
   printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());
}

I get the following error:

Undefined symbols for architecture x86_64:
  "___gxx_personality_v0", referenced from:
      Dwarf Exception Unwind Info (__eh_frame) in cccRGd8K.o
ld: symbol(s) not found for architecture x86_64
collect2: error: ld returned 1 exit status

Any ideas on what it means?

1
It has nothing to do with OpenMP ; see stackoverflow.com/questions/203548/… - damienfrancois

1 Answers

2
votes

You are passing a C++ program to gcc-4.9. Compile with:

g++-4.9 main.cpp -fopenmp -o program

Your program looks like C program. So I suggest you rename it `main.c and you can compile with gcc then:

gcc-4.9 main.c -fopenmp -o program