Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/cplusplus/136.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C++ 编译OpenBLAS C++;“项目给出错误”;架构x86“U 64”的未定义符号;_C++_Compiler Errors_Dot Product_Openblas - Fatal编程技术网

C++ 编译OpenBLAS C++;“项目给出错误”;架构x86“U 64”的未定义符号;

C++ 编译OpenBLAS C++;“项目给出错误”;架构x86“U 64”的未定义符号;,c++,compiler-errors,dot-product,openblas,C++,Compiler Errors,Dot Product,Openblas,很长一段时间以来,我一直试图让OpenBLAS(和其他BLAS库)正常工作,尽管我无法让项目正确编译,但无论我使用什么BLAS库,它总是给出相同类型的错误 我试图运行的代码非常简单,它是来自OpenBlasGit存储库的一些示例代码 #include "cblas.h" #include <cstdio> int main() { int i=0; double A[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0}; double B[6]

很长一段时间以来,我一直试图让OpenBLAS(和其他BLAS库)正常工作,尽管我无法让项目正确编译,但无论我使用什么BLAS库,它总是给出相同类型的错误

我试图运行的代码非常简单,它是来自OpenBlasGit存储库的一些示例代码

#include "cblas.h"
#include <cstdio>

int main()
{
    int i=0;
    double A[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
    double B[6] = {1.0,2.0,1.0,-3.0,4.0,-1.0};
    double C[9] = {.5,.5,.5,.5,.5,.5,.5,.5,.5};
    cblas_dgemm(CblasColMajor, CblasNoTrans, CblasTrans,3,3,2,1,A, 3, B, 3,2,C,3);

    for(i=0; i<9; i++)
        printf("%lf ", C[i]);
    printf("\n");

    return 0;
}
但是,当我尝试运行代码时,会出现以下错误:

使用OpenBLAS时:

使用“英特尔MKL”、dgemm_example.c文件以及
CMakeLists.txt
文件中稍有改动的一行时:

我已经提供了这两种情况下,有一些细节是没有提供的一个错误代码

我在Mac OS上使用克利永,用C++编程。 对于如何解决这一问题的任何帮助,我们将不胜感激


谢谢大家的帮助

我看你的案子没有问题。我只添加了#include“mkl_cblas.h”而不是“clbas.h”。 然后从命令行链接到“英特尔mkl”,如推荐的: -L${MKLROOT}/lib-Wl,-rpath,${MKLROOT}/lib-lmkl_intel_lp64-lmkl_sequential-lmkl_core-lpthread-lm-ldl 然后启动可执行文件,我看到: /a.out
11.000000-9.000000-5.000000-9.000000-21.000000-1.000000-5.000000-1.000000-3.000000

我看你的案子没有问题。我只添加了#include“mkl_cblas.h”而不是“clbas.h”。 然后从命令行链接到“英特尔mkl”,如推荐的: -L${MKLROOT}/lib-Wl,-rpath,${MKLROOT}/lib-lmkl_intel_lp64-lmkl_sequential-lmkl_core-lpthread-lm-ldl 然后启动可执行文件,我看到: /a.out
11.000000-9.000000-5.000000-9.000000-21.000000-1.000000-5.000000-1.000000-3.000000

对不起,这是为OpenBLAS为英特尔MKL设计的吗,我不能让它为MKL工作,我认为这是为了MKL工作吗?对不起,但这是为OpenBLAS为英特尔MKL设计的吗,我不能让它为MKL工作,我想这是为了工作?
include_directories(/Path/To/OpenBlas-0.3.7)
Scanning dependencies of target OpenBlasTesting
[ 50%] Building CXX object CMakeFiles/OpenBlasTesting.dir/main.cpp.o
[100%] Linking CXX executable OpenBlasTesting
Undefined symbols for architecture x86_64:
  "_cblas_dgemm", referenced from:
      _main in main.cpp.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[3]: *** [CMakeFiles/OpenBlasTesting.dir/build.make:84: OpenBlasTesting] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:76: CMakeFiles/OpenBlasTesting.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/OpenBlasTesting.dir/rule] Error 2
gmake: *** [Makefile:118: OpenBlasTesting] Error 2
Scanning dependencies of target MKLTesting
[ 50%] Building C object CMakeFiles/MKLTesting.dir/main.c.o
[100%] Linking C executable MKLTesting
Undefined symbols for architecture x86_64:
  "_MKL_free", referenced from:
      _main in main.c.o
  "_MKL_malloc", referenced from:
      _main in main.c.o
  "_cblas_dgemm", referenced from:
      _main in main.c.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
gmake[3]: *** [CMakeFiles/MKLTesting.dir/build.make:84: MKLTesting] Error 1
gmake[2]: *** [CMakeFiles/Makefile2:76: CMakeFiles/MKLTesting.dir/all] Error 2
gmake[1]: *** [CMakeFiles/Makefile2:83: CMakeFiles/MKLTesting.dir/rule] Error 2
gmake: *** [Makefile:118: MKLTesting] Error 2