Compiling openmp with GNU gcc fails in Windows

I have Windows 8 64bit operating system.

I wanted to experiment with following C code for OpenMP functionality:

hello.c program

#include <stdio.h>
#include <stdlib.h>

int main()
    #pragma omp parallel
    printf("Hello world!\n");
    return 0;

While I tried to run the program from command prompt using: gcc -fopenmp hello.c

I got the following error:

c:/mingw/bin/../lib/gcc/mingw32/4.8.1/../../../../mingw32/bin/ld.exe: cannot fin
d -lpthread
collect2.exe: error: ld returned 1 exit status

I have C:\MinGW in my path with gcc 4.8.1.

What is it I am missing?


  • Thanks osgx,

    As a newbie I couldn't make out what these pthreads meant. But after all I found solution to my problem. I installed gcc 4.8.2 64 bit on my machine from It changed the environment variable (in path) itself. After finishing installation, I restarted my computer and when I typed:

    gcc -fopenmp hello.c

    for the above code in command line, the code worked.