OpenBlas:使用Xcode时找不到CBLAS.H

发布于 2025-02-11 08:51:19 字数 564 浏览 0 评论 0原文

使用CBLA时,我会遇到问题。我是新手使用C ++进行数字的新手,我知道OpenBlas是执行线性代数计算的著名库之一。我在M1 MacBook中使用BREW安装OpenBlas。安装完成后,我按照输出指令简单地将这些命令键入终端。但是,当我使用以下示例测试OpenBlas时,

#include <iostream>
#include "cblas.h"
#include "lapacke.h"

using namespace std;

int main(){
    float b[] = {3, 1, 3, 1, 5};
    cblas_sasum(5, b, 1);
    cout << "Program finished";
}

Xcode说致命错误:'CBLAS.H'文件找不到。因此,我想知道如何解决这个问题。感谢任何评论。

I encounter a problem when using cblas. I am new to use C++ to do numerics and I know Openblas is one of the famous library to perform linear algebra computation. I use brew install openblas in my M1 Macbook. When the installation finishes, I follow the output instruction by simply typing these commands in terminal. However, when I use the following example to test openblas,

#include <iostream>
#include "cblas.h"
#include "lapacke.h"

using namespace std;

int main(){
    float b[] = {3, 1, 3, 1, 5};
    cblas_sasum(5, b, 1);
    cout << "Program finished";
}

Xcode says that fatal error: 'cblas.h' file not found. Therefore, I am wondering how to solve this issue. I appreciate any comment.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

酸甜透明夹心 2025-02-18 08:51:19

经过几次反复试验后,我通过编写以下makefile来解决我的问题:

CC = g++
INCLUDES = -I/opt/homebrew/Cellar/openblas/0.3.20/include
CPPFLAGS = -g -Wall $(INCLUDES)
LDFLAGS = -L/opt/homebrew/opt/openblas/lib

all:main.o /opt/homebrew/opt/openblas/lib/libopenblas.a
        $(CC) main.o $(LDFLAGS) -lopenblas -o main.out

main.o:main.cpp /opt/homebrew/Cellar/openblas/0.3.20/include/cblas.h
        $(CC) $(CPPFLAGS) -c main.cpp
clean:
        rm -f main.out

我跟随此 post 写一个makefile,它确实有效。要使用Xcode编译main.cpp文件,我们需要将链接添加到Xcode中。在此

After several trial and error, I solve my problem by writing the following makefile:

CC = g++
INCLUDES = -I/opt/homebrew/Cellar/openblas/0.3.20/include
CPPFLAGS = -g -Wall $(INCLUDES)
LDFLAGS = -L/opt/homebrew/opt/openblas/lib

all:main.o /opt/homebrew/opt/openblas/lib/libopenblas.a
        $(CC) main.o $(LDFLAGS) -lopenblas -o main.out

main.o:main.cpp /opt/homebrew/Cellar/openblas/0.3.20/include/cblas.h
        $(CC) $(CPPFLAGS) -c main.cpp
clean:
        rm -f main.out

I follow this post to write a makefile and it does work. To use Xcode to compile the main.cpp file, we need to add linker into Xcode. The instruction is discussed in this youtube video

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文