openmp on dev c++

13,825

Solution 1

I do not know Dev C++, but to enable openmp you also need to add the flag -fopenmp to your compiler. Additional to linking to omp.

With g++ it look like this

g++ yourProgram.cpp -o yourProgram -lgomp -fopenmp

-fopenmp will tell the compiler to generate parallel code. I hope this will help.

Solution 2

Tools > Compiler Options > Check the option "Add the following commands when compiler is called" > in the text area put "-fopenmp"

Compile and execute again :)

Solution 3

You have to include -fopenmp in

  1. Project-> Project Option->Parameters - Link and
  2. Tools ->Compiler Options (General) (check "add the following commands when calling the compiler" and include -fopenmp in the textBox

I have also included #include <omp.h> dev-c++ version 5.6.1

Share:
13,825

Related videos on Youtube

user1019083
Author by

user1019083

Updated on June 24, 2022

Comments

  • user1019083
    user1019083 about 2 years

    Is there anyway to use openmp with dev c++. I have seen links on how to use in Visual Studio, but i am more comfortable with Dev C++ interface. Adding /openmp in the linker command line doesnt work either. I couldnt find the library to download too. Am i missing something. I tried running this sample code:

    #include <stdio.h> 
    #include <stdlib.h>
    
    int main(int argc, char *argv[])
    {
        #pragma omp parallel
        { 
           printf("Hello, world.\n");
        }
       return 0;
     }
    

    From where I read it was mentioned Output on a computer with 2 Cores and 2 threads will be hello world printed twice. I have a core i7 but it was printed only once.

    • Konrad Rudolph
      Konrad Rudolph over 12 years
      Dev-C++ is outdated. Its development has stopped half a decade ago. Please use a modern IDE.
  • Babaji
    Babaji over 4 years
    This helps. I think this is the answer that should be selected as the right one since the other one doesn't tell you how to do this on Dev C++.