OpenMP omp_get_wtime g ++ 32bits

时间:2017-07-20 18:28:17

标签: c++ gcc openmp

为了测量程序某些部分的时间,我想使用OpenMP中的omp_get_wtime()函数。我只能用32位编译项目(使用-m32 gcc选项)。我得到了那些错误:

libgomp.a(time.o): In function 'gomp_ialias_omp_get_wtick':
  undefined reference to 'clock_getres'
libgomp.a(time.o): In function 'gomp_ialias_omp_get_wtime':
  undefined reference to 'clock_gettime'

虽然我在64位编译时没有任何错误(我做了一个简单的测试)。

我使用-fopenmp链接openmp。我尝试添加-gomp,但它没有改变任何内容。

我在2012 Cent OS版本(64位)下运行,并使用gcc 4.4.7进行编译 为了使它更有趣,我无法使用apt升级或安装任何内容,但我可以从一些缺少库的源代码编译。

1 个答案:

答案 0 :(得分:2)

旧版本的glibc在clock_getres中定义clock_gettimelibrt,而不是libc,因此您可能只需要与-lrt进行关联。