对omp_get_wtime的未定义引用 [英] undefined reference to omp_get_wtime

查看:1064
本文介绍了对omp_get_wtime的未定义引用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我找不到要在Windows(Vista)下的GCC(4.8)中链接的wich库.我尝试了-fopenmp -llibgomp -lgomp编译器指令,但是没有一个有效.

我已经拥有带有POSIX的GCC(因此,如果启用C ++ 11,则std :: thread可以工作),问题似乎是,搜索正确的库不能提供有用的结果(即使在GCC/mingw文档中进行搜索).

所以基本上我无法得到答案有效(该答案声称适用于大多数编译器,但不会)无法提供有关如何使其正常运行的其他信息,因此我无法验证其是否确实正常运行

现在很高兴提供更多信息,以使其在大多数系统上都能正常工作.

谢谢!

解决方案

基于GCC 4.8.1的MinGW-w64,来自

内部版本:

gcc main.c -lgomp -o test.exe

结果:

1381572544.299000

示例:C ++


main.cpp

#include <iostream>
#include <omp.h>

using std::cout;
using std::endl;

int
main() {
  double x = omp_get_wtime();

  cout << x << endl;
}

内部版本:

g++ main.cpp -lgomp -o test.exe

结果:

1.38158e+009

结论


您的MinGW发行版可能出了点问题.否则,我看不出任何不起作用的原因.尝试上面的方法,看看效果如何.

I cannot find wich library to link in GCC (4.8) under windows (vista). I tried -fopenmp -llibgomp -lgomp compiler directives but no one works.

I already have GCC with POSIX (so std::thread working if enabling C++11), the problem seems that searching for the right library does not provide usefull results (even searching on GCC/mingw documentation).

so basically I can't get this answer working (the answer claimed to work on most compilers, but don't provide additional info on how to get it working so I can't verify if it is working really or not)

would be nice to provide now additional informations to get it working on most systems..

Thanks!

解决方案

MinGW-w64 based on GCC 4.8.1 from here has no problems so far.

Example: C


main.c

#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

Example: C++


main.cpp

#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

Conclusion


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.

这篇关于对omp_get_wtime的未定义引用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆