0

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?

Brian Cain
  • 14,403
  • 3
  • 50
  • 88
Loumiakas
  • 5
  • 4
  • It has nothing to do with OpenMP ; see http://stackoverflow.com/questions/203548/undefined-symbol-gxx-personality-v0-on-link – damienfrancois Nov 20 '14 at 20:58

1 Answers1

2

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
P.P
  • 117,907
  • 20
  • 175
  • 238