Starosta
Starosta

Reputation: 25

How can i compile c++ with openmp? (using g++ in windows 10)

i'm new in c++ programming. Also new in openMP. I have this simple code

#include <stdio.h>
#include <omp.h>

int main(int argc, char const *argv[])
{
    #pragma omp parallel
    printf("This is thread %d out of %d\n", omp_get_thread_num(), omp_get_num_threads());
    return 0;
}

when i try to compile it using

g++ -fopenmp file_name.cpp

in the cmd, i get this error

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

I use windows 10, and the gcc version is 6.3.0. How can i fix this? thanks

Upvotes: 0

Views: 3969

Answers (1)

Maple
Maple

Reputation: 74

For MinGW32, This would help.

Or you can use TDM-GCC. You can download full TDM-GCC installers and be sure to enable openmp support when you install. Packages is also OK like gcc-5.1.0-tdm64-1-core.zip with gcc-5.1.0-tdm64-1-openmp.zip extracted to the same folder.

Upvotes: 1

Related Questions