User forums > Help
Compile OpenMp File
dm83:
Hi everybody,
I'm a new user on this forum so i excuse with you for all my mistakes.
i have to compile a c source file in OpenMp ambient. when i compile the file, the code blocks' compiler don't recognize the parallel regions. In
fact i should add the -fopenmp option to compiler.
How can i do this?
Thank you very very much.
Bye bye all!!!
killerbot:
build options of your project -> Compiler settings -> Other options :
put there the -fopenmp
Maybe you also need to link with an openmp library, it has been some time since I used OpenMP, but I had it working with CB ;-)
dm83:
Thank you but I have already do this but it didn't work.
I have also imported the omp.h library.
What can i do?
dm83:
This is my code:
#include <omp.h>
#include <stdio.h>
#include <stdlib.h>
void main()
{
int x,nt,tid;
int ris;
omp_set_nested(1);
ris=omp_get_nested();
if (ris)
printf("Nested parallelism enabled\n");
omp_set_num_threads(5);
#pragma omp parallel private (nt,tid)
{
tid = omp_get_thread_num();
printf("Ciao sono il thread %d\n",tid);
nt = omp_get_num_threads();
if (omp_get_thread_num()==1)
printf("Il numero di threads e': %d\n",nt);
}
omp_set_num_threads(3);
#pragma omp parallel private (x)
{
x=x+1;
printf("Valore = %d\n",x);
}
}
and this is the response of the compiler:
Prova.c undefined reference to 'omp_set_nested'
Prova.c undefined reference to 'omp_get_nested'
Prova.c undefined reference to 'omp_set_num_threads'
Prova.c undefined reference to 'GOMP_parallel_start'
Prova.c undefined reference to 'GOMP_parallel_end'
Prova.c undefined reference to 'omp_set_num_threads'
Prova.c undefined reference to 'GOMP_parallel_start'
Prova.c undefined reference to 'GOMP_parallel_end'
build finished: 8 errors, 0 warnings
oBFusCATed:
Read this please: http://wiki.codeblocks.org/index.php?title=FAQ#Q:_How_do_I_troubleshoot_an_compiler_problem.3F
Also please use code tags for such long pastes
Navigation
[0] Message Index
[#] Next page
Go to full version