我找不到要在Windows(Vista)下的GCC(4.8)中链接的wich库。我尝试了-fopenmp -llibgomp -lgomp编译器指令,但是没有人可以使用。
我已经在POSIX上安装了GCC(如果启用C ++ 11,则std :: thread可以工作),问题似乎在于,搜索正确的库不能提供有用的结果(即使在GCC / mingw文档上进行搜索)。
因此,基本上我无法获得此答案(该答案声称可在大多数编译器上使用,但未提供有关如何使其正常工作的其他信息,因此我无法验证其是否确实有效)
现在提供其他信息以使其在大多数系统上都能正常工作将是非常不错的。
谢谢!
基于GCC 4.8.1从MinGW的-W64 这里有没有问题为止。
#include <omp.h>
#include <stdio.h>
int
main() {
double x = omp_get_wtime();
printf("%f\n", x);
}
Run Code Online (Sandbox Code Playgroud)
建立:
gcc main.c -lgomp -o test.exe
Run Code Online (Sandbox Code Playgroud)
结果:
1381572544.299000
Run Code Online (Sandbox Code Playgroud)
#include <iostream>
#include <omp.h>
using std::cout;
using std::endl;
int
main() {
double x = omp_get_wtime();
cout << x << endl;
}
Run Code Online (Sandbox Code Playgroud)
建立:
g++ main.cpp -lgomp -o test.exe
Run Code Online (Sandbox Code Playgroud)
结果:
1.38158e+009
Run Code Online (Sandbox Code Playgroud)
您的MinGW发行版可能有问题。否则,我看不出任何不起作用的原因。尝试上面的一种,看看如何进行。