gpt4 book ai didi

c++ - 在macOS Catalina上编译Intel MKL CBLAS示例文件的问题

转载 作者:行者123 更新时间:2023-12-02 10:19:04 24 4
gpt4 key购买 nike

我想解决C++中的一个问题,其中涉及寻找方程组的解决方案。我看到英特尔的MKL软件包为此提供了必要的工具。我已经下载了整个库并安装了它。
首先,我想看看一切是否正常,因此,编译intel提供的一个简单示例(请参阅C源文件here)是我尝试的第一件事。它是一个通过cblas_dgem函数将两个矩阵相乘的程序。但是,我收到很多警告
和一个错误:

basavyr@Roberts-MacBook-Pro Desktop % g++ mkl-lab-solution.c
clang: warning: treating 'c' input as 'c++' when in C++ mode, this behavior is deprecated [-Wdeprecated]
In file included from mkl-lab-solution.c:30:
In file included from /usr/local/include/stdio.h:64:
/usr/local/include/_stdio.h:93:16: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
unsigned char *_base;
^
/usr/local/include/_stdio.h:93:16: note: insert '_Nullable' if the pointer may be null
unsigned char *_base;
^
_Nullable
/usr/local/include/_stdio.h:93:16: note: insert '_Nonnull' if the pointer should never be null
unsigned char *_base;
^
_Nonnull
/usr/local/include/_stdio.h:138:32: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int (* _Nullable _read) (void *, char *, int);
^
/usr/local/include/_stdio.h:138:32: note: insert '_Nullable' if the pointer may be null
int (* _Nullable _read) (void *, char *, int);
^
_Nullable
/usr/local/include/_stdio.h:138:32: note: insert '_Nonnull' if the pointer should never be null
int (* _Nullable _read) (void *, char *, int);
^
_Nonnull
/usr/local/include/_stdio.h:138:40: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int (* _Nullable _read) (void *, char *, int);
^
/usr/local/include/_stdio.h:138:40: note: insert '_Nullable' if the pointer may be null
int (* _Nullable _read) (void *, char *, int);
^
_Nullable
/usr/local/include/_stdio.h:138:40: note: insert '_Nonnull' if the pointer should never be null
int (* _Nullable _read) (void *, char *, int);
^
_Nonnull
/usr/local/include/_stdio.h:139:35: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
fpos_t (* _Nullable _seek) (void *, fpos_t, int);
^
/usr/local/include/_stdio.h:139:35: note: insert '_Nullable' if the pointer may be null
fpos_t (* _Nullable _seek) (void *, fpos_t, int);
^
_Nullable
/usr/local/include/_stdio.h:139:35: note: insert '_Nonnull' if the pointer should never be null
fpos_t (* _Nullable _seek) (void *, fpos_t, int);
^
_Nonnull
/usr/local/include/_stdio.h:140:32: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int (* _Nullable _write)(void *, const char *, int);
^
/usr/local/include/_stdio.h:140:32: note: insert '_Nullable' if the pointer may be null
int (* _Nullable _write)(void *, const char *, int);
^
_Nullable
/usr/local/include/_stdio.h:140:32: note: insert '_Nonnull' if the pointer should never be null
int (* _Nullable _write)(void *, const char *, int);
^
_Nonnull
/usr/local/include/_stdio.h:140:46: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int (* _Nullable _write)(void *, const char *, int);
^
/usr/local/include/_stdio.h:140:46: note: insert '_Nullable' if the pointer may be null
int (* _Nullable _write)(void *, const char *, int);
^
_Nullable
/usr/local/include/_stdio.h:140:46: note: insert '_Nonnull' if the pointer should never be null
int (* _Nullable _write)(void *, const char *, int);
^
_Nonnull
/usr/local/include/_stdio.h:144:18: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
struct __sFILEX *_extra; /* additions to FILE to not break ABI */
^
/usr/local/include/_stdio.h:144:18: note: insert '_Nullable' if the pointer may be null
struct __sFILEX *_extra; /* additions to FILE to not break ABI */
^
_Nullable
/usr/local/include/_stdio.h:144:18: note: insert '_Nonnull' if the pointer should never be null
struct __sFILEX *_extra; /* additions to FILE to not break ABI */
^
_Nonnull
In file included from mkl-lab-solution.c:30:
/usr/local/include/stdio.h:67:13: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
extern FILE *__stdinp;
^
/usr/local/include/stdio.h:67:13: note: insert '_Nullable' if the pointer may be null
extern FILE *__stdinp;
^
_Nullable
/usr/local/include/stdio.h:67:13: note: insert '_Nonnull' if the pointer should never be null
extern FILE *__stdinp;
^
_Nonnull
/usr/local/include/stdio.h:386:41: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int (* _Nullable)(void *, const char *, int),
^
/usr/local/include/stdio.h:386:41: note: insert '_Nullable' if the pointer may be null
int (* _Nullable)(void *, const char *, int),
^
_Nullable
/usr/local/include/stdio.h:386:41: note: insert '_Nonnull' if the pointer should never be null
int (* _Nullable)(void *, const char *, int),
^
_Nonnull
/usr/local/include/stdio.h:386:55: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int (* _Nullable)(void *, const char *, int),
^
/usr/local/include/stdio.h:386:55: note: insert '_Nullable' if the pointer may be null
int (* _Nullable)(void *, const char *, int),
^
_Nullable
/usr/local/include/stdio.h:386:55: note: insert '_Nonnull' if the pointer should never be null
int (* _Nullable)(void *, const char *, int),
^
_Nonnull
/usr/local/include/stdio.h:387:44: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
fpos_t (* _Nullable)(void *, fpos_t, int),
^
/usr/local/include/stdio.h:387:44: note: insert '_Nullable' if the pointer may be null
fpos_t (* _Nullable)(void *, fpos_t, int),
^
_Nullable
/usr/local/include/stdio.h:387:44: note: insert '_Nonnull' if the pointer should never be null
fpos_t (* _Nullable)(void *, fpos_t, int),
^
_Nonnull
/usr/local/include/stdio.h:388:41: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
int (* _Nullable)(void *));
^
/usr/local/include/stdio.h:388:41: note: insert '_Nullable' if the pointer may be null
int (* _Nullable)(void *));
^
_Nullable
/usr/local/include/stdio.h:388:41: note: insert '_Nonnull' if the pointer should never be null
int (* _Nullable)(void *));
^
_Nonnull
/usr/local/include/stdio.h:384:6: warning: pointer is missing a nullability type specifier
(_Nonnull, _Nullable, or _Null_unspecified) [-Wnullability-completeness]
FILE *funopen(const void *,
^
/usr/local/include/stdio.h:384:6: note: insert '_Nullable' if the pointer may be null
FILE *funopen(const void *,
^
_Nullable
/usr/local/include/stdio.h:384:6: note: insert '_Nonnull' if the pointer should never be null
FILE *funopen(const void *,
^
_Nonnull
mkl-lab-solution.c:85:15: warning: conversion from string literal to 'char *' is deprecated
[-Wc++11-compat-deprecated-writable-strings]
print_arr(N,"a", a);
^
mkl-lab-solution.c:86:15: warning: conversion from string literal to 'char *' is deprecated
[-Wc++11-compat-deprecated-writable-strings]
print_arr(N,"b", b);
^
mkl-lab-solution.c:87:15: warning: conversion from string literal to 'char *' is deprecated
[-Wc++11-compat-deprecated-writable-strings]
print_arr(N,"c", c);
^
16 warnings generated.
Undefined symbols for architecture x86_64:
"_cblas_dgemm", referenced from:
Dgemm_multiply(double*, double*, double*, int) in mkl-lab-solution-96315a.o
ld: symbol(s) not found for architecture x86_64
**clang: error:** linker command failed with exit code 1 (use -v to see invocation)
basavyr@Roberts-MacBook-Pro Desktop %
使用以下命令进行编译: g++ -m64 -I${MKLROOT}/include mkl-lab-solution.c我正在运行macOS Catalina(10.15.3)。我的C++编译器没有问题(到目前为止,我运行的所有程序都没有问题)
任何想法为什么会发生这种情况以及如何解决该问题?

最佳答案

您需要链接到mkl的库。请咨询mkl链接程序顾问以查看需要链接的mkl库的列表。这是该顾问的列表:https://software.intel.com/en-us/articles/intel-mkl-link-line-advisor

关于c++ - 在macOS Catalina上编译Intel MKL CBLAS示例文件的问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/61007114/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com