windows - 将 OpenBLAS 链接到 MinGW
问题描述
我正在尝试将OpenBLAS库与Windows 上的MinGW w64编译器链接起来。
这是我的代码:
#include <cstdio>
#include <cblas.h>
#include <cstdlib>
int main(){
double m[10],n[10];
int i, result;
for(i=0;i<10;i++)
m[i] = 1.0l*rand()/RAND_MAX;
for(i=0;i<10;i++)
n[i] = 1.0l*rand()/RAND_MAX;
result = cblas_ddot(10, m, 1, n, 1);
return 0;
}
并使用此命令编译:
g++ ^ -IC:\OpenBLAS-0.3.6-x64\include -LC:\OpenBLAS-0.3.6-x64\lib -lopenblas blas.cpp
并得到一个错误
undefined reference to `cblas_ddot'
我从这里下载了预编译的二进制文件并使用 64 位 Windows,g++ (x86_64-win32-seh-rev0, Built by MinGW-W64 project) 8.1.0
我该如何解决这个错误?
解决方案
一般建议是始终将源文件和目标文件放在链接库之前。
通常,并非所有库函数都被使用,而仅使用主要代码源所需的函数。然后链接器需要在查看库之前知道未定义的符号。
然后放在blas.cpp
之前-lopenblas
应该工作。
g++ ^ -IC:\OpenBLAS-0.3.6-x64\include -LC:\OpenBLAS-0.3.6-x64\lib blas.cpp -lopenblas
推荐阅读
- python - 在 Google Colab 上使用最新的 Python 版本
- javascript - 如何在反应数据网格组件中显示 csv 文件数据
- c# - WCF 服务。如何返回自定义错误/信息页面
- java - Webflux websocketclient,如何在同一个会话中发送多个请求[设计客户端库]
- sql - 查询给出双重结果而不是单一结果
- ios - UIButton touch up inside 在某些设备上不调用 IBAction
- python - 关于如何在 docker 中管理 python 模块的建议?
- html - 小屏幕上的CSS底部属性问题
- javascript - 无法在 d3js 条形图上定位工具提示
- android-gradle-plugin - build:gradle:3.2.1:程序类型已经存在:android.support.v4.accessibilityservice