错误"undefined reference to omp_get_wtime"
Error "undefined reference to omp_get_wtime"
我在Windows(Vista(下的GCC(4.8(中找不到要链接的库。我尝试了-fopenmp -llibgomp -lgomp编译器指令,但没有一个有效。
我已经有了带有 POSIX 的 GCC(所以如果启用 C++11,std::thread 就可以工作了(。问题似乎是搜索正确的库并不能提供有用的结果(即使在GCC/MinGW文档中搜索也是如此(。
所以基本上我无法让这个答案工作(答案声称适用于大多数编译器,但它没有提供有关如何使其工作的其他信息,所以我无法验证它是否真的有效(。
现在提供额外的信息以使其在大多数系统上工作会很好......
基于
GCC 4.8.1的MinGW-w64到目前为止没有任何问题。
示例:C
<小时 />主.c
#include <omp.h>
#include <stdio.h>
int
main() {
double x = omp_get_wtime();
printf("%fn", x);
}
建:
gcc main.c -lgomp -o test.exe
结果:
1381572544.299000
示例:C++
<小时 />主.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 分布可能有问题。否则,我认为它没有任何理由不起作用。试试上面的一个,看看它是如何进行的。
相关文章:
- Cpp-Tuple使用带有变量的get
- 通过 get-Method 访问变量在类外不起作用
- 为什么无论你输入什么,这"while(cin.get(str,3))"只运行一次?
- Boost.Asio/OpenSSL HTTPS GET certificate trouble
- C++中是否有任何函数等同于python中字典的get函数?
- 使用istringstearm和get行缓慢读取文件
- 如何将 c++ get 函数代码转换为 opencv 算法中使用的 python
- 使用 cin.get() 初始化字符数组
- std::variant<>::get() 不能使用 Apple LLVM 10.0 编译
- 编写 cin.get() 以接收字符数组时出现问题
- 作用域枚举和标准::get
- Visual Studio 2017 中的 cpprestapi 问题找不到 POST/GET 常量
- 在 C++/C 中使用 CURL 发出带有数据文件的 GET HTTP 请求
- 使用"push_back"作为带有"get"函数C++的向量
- 使用 cin.get 读取字符数组
- 如何使用 fstream 的 .get 字符串?
- std::get like (partial) template specialization
- 从 unique_ptr::get 发送指针作为指针引用进入函数
- addr2line get 行号始终返回 0
- unique_ptr<T>::get() 返回的指针在原始unique_ptr被销毁后不是 nullptr