-1

I just installed openMP just running

  • brew install gcc

Then I compiled my code using

  • gcc-10 -o task -fopenmp task.c

However I got the error message:

Undefined symbols for architecture x86_64: "_main", referenced from: implicit entry/start for main executable ld: symbol(s) not found for architecture x86_64 collect2: error: ld returned 1 exit status

my code is:

1. #include <omp.h>
2. #include <iostream>
3. using namespace std; 
4.
5. #define TAMA_NTHREADS 4
6.
7.
8. int main (int argc, const char * argv[]){
9.
10.    
11.   int nProcessors = omp_get_max_threads();
12.
13.   cout<<"Numero di core disponibili: " << nProcessors << endl;
14.
15.   omp_set_num_threads(nProcessors);
16.
17.   cout << "Numero thread fuori pragma: " << omp_get_num_threads() << endl;
18.
19.   #pragma omp parallel
20.      {
21.         cout << endl <<"Numero di thread in pragma: " << omp_get_num_threads() << endl;
22.         cout << "Sono il thread numero: " << omp_get_thread_num(); 
23.         cout << " E ti saluto! " << endl; 
24.      }
25.   
26.   exit(0);
27.}

May someone help me please?

2
  • That's C++ code that you are trying to compile as C. Rename the file to task.cc and use g++-10 instead. Commented Feb 10, 2021 at 8:33
  • yes it does. :) Commented Feb 10, 2021 at 9:52

1 Answer 1

0

"That's C++ code that you are trying to compile as C. Rename the file to task.cc and use g++-10 instead". Hirsto this solved the problem thank you. Anyway it works even if I do not rename the file.

Sign up to request clarification or add additional context in comments.

Comments

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.