Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Linker library for OpenMP for Snow Leopard?

Currently, I am trying out OpenMP on XCode 3.2.2 on Snow Leopard:

#include <omp.h>
#include <iostream>
#include <stdio.h>

int main (int argc, char * const argv[]) {

    #pragma omp parallel
    printf("Hello from thread %d, nthreads %d\n", omp_get_thread_num(), omp_get_num_threads());
    return 0;
}

I didn't include any linking libraries yet, so the linker complains:

"_omp_get_thread_num", referenced from: _main in main.o
"_omp_get_num_threads", referenced from: _main in main.o

OK, fine, no problem, I take a look in the existing framework, looking for keywords such as openmp or omp... here comes the problem, where is the linking library? Or should I say, what is the name of the linking library for openMP? Is it dylib, framework or what? Or do I need to get it from somewhere first?

like image 958
Karl Avatar asked May 24 '10 15:05

Karl


3 Answers

In case anyone is wondering how to compile this in XCode 4, I had to enable OpenMP support as well.

I enabled OpenMP support by clicking on the Project, then under Build Options, I changed Enable OpenMP Support from No to Yes.

Also, I had to change the Compiler Version from "LLVM 2.0" to "GCC 4.2" or "LLVM GCC 4.2". Otherwise, the compiler couldn't find "omp.h".

like image 127
Chris Livdahl Avatar answered Nov 16 '22 18:11

Chris Livdahl


No need. We only need to enable OpenMP support under project setting.

like image 22
Karl Avatar answered Nov 16 '22 17:11

Karl


gcc -fopenmp -o mycode mycode.c

like image 1
Charles Doutriaux Avatar answered Nov 16 '22 17:11

Charles Doutriaux