Unknown pragma when compiling OpenMP with g++

c++, g++, openmp

Solution

This is warning appears if you compile OpenMP code without the `-fopenmp` flag. The `g++` man page tells us what `-fopenmp` does:

Enable handling of OpenMP directives "#pragma omp" in C/C++ and "!$omp" in Fortran. When -fopenmp is specified, the compiler generates parallel code according to the OpenMP Application Program Interface v3.0 http://www.openmp.org/. This option implies -pthread, and thus is only supported on targets that have support for -pthread

Problem

I am working on C++ code which contains `openmp pragmas`. While trying to compile with `g++`, I am receiving the following error message: `ignoring #pragma omp parallel [-Werror=unknown-pragmas]` I understand that the error is from not using `fopenmp` flag with in the makefile. I have tried including the `fopenmp` flag to the `CXXFLAGS`. Still, it is not working. Would anyone think of solutions to work around this issue? Note: This question looks like a repeat question of similar question on same error and I have gone through and tried it too. Therefore, I would request this question not to be flagged as repeat question.

Original source