- android - RelativeLayout 背景可绘制重叠内容
- android - 如何链接 cpufeatures lib 以获取 native android 库?
- java - OnItemClickListener 不起作用,但 OnLongItemClickListener 在自定义 ListView 中起作用
- java - Android 文件转字符串
这是我第一次尝试使用 ATLAS。我无法正确链接它。这是一个非常简单的 sgemm 程序:
...
#include <cblas.h>
const int M=10;
const int N=8;
const int K=5;
int main()
{
float *A = new float[M*K];
float *B = new float[K*N];
float *C = new float[M*N];
// Initialize A and B
cblas_sgemm(CblasRowMajor, CblasNoTrans, CblasNoTrans, M, N, K, 1.0, A, K, B, N, 0.0, C, N);
...
}
当我在带有标准 ATLAS 安装的 linux 平台上编译它时,出现链接错误:
g++ test.c -lblas -lcblas -latlas -llapack
/tmp/cc1Gu7sr.o: In function `main':
test.c:(.text+0x29e): undefined reference to `cblas_sgemm(CBLAS_ORDER, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, int, int, int, float, float const*, int, float const*, int, float, float*, int)'
collect2: ld returned 1 exit status
如您所见,我尝试提供不同的库组合但没有帮助。我做错了什么?
最佳答案
你需要
extern "C"
{
#include <cblas.h>
}
因为你用 g++
编译。
或者你甚至可以做
#ifdef __cplusplus
extern "C"
{
#endif
#include <cblas.h>
#ifdef __cplusplus
}
#endif
也能够编译为 C。
当您在 C++ 中编译时,名称会被破坏。但是由于 cblas 是用 C 语言编译的,所以导出的符号没有错位的名称。所以你必须指示编译器寻找 C 风格的符号。
关于c++ - ATLAS gemm 将 undefined reference 链接到 'cblas_sgemm',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10786237/
我在使用 cblas 的 sgemm 函数时遇到问题。 代码如下: #include #include #include #include #include #define MATRIX_D
我正在尝试使用 vecLibs 的 cblas 将两个矩阵相乘: #include #include #include #include int main (void) { float
我有 100 个 3x3x3 矩阵,我想将它们与另一个大小为 3x5x5 的大矩阵相乘(类似于用多个滤波器对一个图像进行卷积,但不完全一样)。 为了解释起见,这就是我的大矩阵的样子: >>> x =
我正在尝试使用 cblas_sgemm 对两个整数矩阵进行快速矩阵乘法。 现在它正在返回全零。 我运行了一个快速的原始矩阵乘法来仔细检查预期的输出数据,它们不应该为零。 工作 朴素的方法: typed
我有以下生成文件 g++ -Wall -O3 -g -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=0 Matrix.cc -L /usr/lib64/libcblas.so.
我正在尝试安装 numpy==1.10.2 , scipy和 matplotlib在基于 opensuse 的服务器上.我已经安装了 numpy在 virtualenv来自源代码(我也尝试过 pip
我有一个函数指针数组,我用它来调用适当的 cblas_xgemm(例如,cblas_dgemm 或 cblas_sgemm 等,来自 ATLAS/CBLAS)。 当我告诉它通过函数指针使用 cblas
这是我第一次尝试使用 ATLAS。我无法正确链接它。这是一个非常简单的 sgemm 程序: ... #include const int M=10; const int N=8; const int
我是一名优秀的程序员,十分优秀!