Eclipse Build Configuration for OpenMP

I am trying to learn OpenMP starting with the following simple snippet

#include <stdio.h> #include <stdlib.h> int main(void) { #pragma omp parallel printf("Hello OpenMP!\n"); return 0; } 

Just compilation from the command line works:

 cls ~/Desktop $ gcc -fopenmp HelloOpenMP.c -o HelloOpenMP cls ~/Desktop $ ./HelloOpenMP Hello OpenMP! Hello OpenMP! 

However, I would like to use Eclipse with CDT. I created a new OpenMP assembly configuration and tried to add the -fopenmp flag to Miscellaneous by copying other settings from the Debug assembly configuration.

enter image description here

Build failed with

 14:56:16 **** Incremental Build of configuration OpenMP for project HelloOpenMP **** make all Building file: ../src/HelloOpenMP.c Invoking: GCC C Compiler gcc -O0 -g3 -Wall -c -fmessage-length=0 -fopenmp -MMD -MP -MF"src/HelloOpenMP.d" -MT"src/HelloOpenMP.d" -o "src/HelloOpenMP.o" "../src/HelloOpenMP.c" Finished building: ../src/HelloOpenMP.c Building target: HelloOpenMP Invoking: MacOS XC Linker gcc -o "HelloOpenMP" ./src/HelloOpenMP.o Undefined symbols for architecture x86_64: "_GOMP_parallel_end", referenced from: _main in HelloOpenMP.o "_GOMP_parallel_start", referenced from: _main in HelloOpenMP.o ld: symbol(s) not found for architecture x86_64 collect2: ld returned 1 exit status make: *** [HelloOpenMP] Error 1 

So, I think this was the wrong place to add the -fopenmp compiler option? What configuration should I use to create using OpenMP?

+6
source share
1 answer

Add the -fopenmp flag to the linker section.

+12
source

Source: https://habr.com/ru/post/926952/


All Articles