I cannot find which library to link in GCC (4.8) under Windows (Vista). I tried the -fopenmp -llibgomp -lgomp compiler directives, but none works.
I already have GCC with POSIX (so std::thread is working if enabling C++11). The problem seems that searching for the right library does not provide useful results (even searching in GCC/MinGW documentation).
So basically I can't get this answer working (the answer claimed to work on most compilers, but it doesn’t provide additional information on how to get it working, so I can't verify if it is really working or not).
It would be nice to provide now additional information to get it working on most systems...
MinGW-w64 based on GCC 4.8.1 from here has no problems so far.
#include <omp.h>
#include <stdio.h>
int
main() {
double x = omp_get_wtime();
printf("%f\n", x);
}
Build:
gcc main.c -lgomp -o test.exe
Result:
1381572544.299000
#include <iostream>
#include <omp.h>
using std::cout;
using std::endl;
int
main() {
double x = omp_get_wtime();
cout << x << endl;
}
Build:
g++ main.cpp -lgomp -o test.exe
Result:
1.38158e+009
Probably something is wrong with your MinGW distribution. Otherwise I don't see any reason for it not to work. Try the above one and see how it goes.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With