Linking with BLAS OS X

Linking with BLAS OS X

本文关键字:OS BLAS with Linking      更新时间:2023-10-16

我目前正在尝试使用我不太熟悉的库编译程序。当我运行编译器时,我得到以下输出/错误:

Undefined symbols for architecture x86_64:
  "_cblas_ddot", referenced from:
      shark::LDA::train(shark::LinearClassifier<shark::blas::vector<double> >&, shark::LabeledData<shark::blas::vector<double>, unsigned int> const&) in libshark.a(LDA.cpp.o)
      shark::LDA::train(shark::LinearClassifier<shark::blas::vector<double> >&, shark::WeightedLabeledData<shark::blas::vector<double>, unsigned int> const&) in libshark.a(LDA.cpp.o)

我目前的想法是,这是从丢失的BLAS库,我刚刚下载和编译(从fortran代码?)。

用于编译的命令行参数如下所示

g++ -o example -I/to/boost/include -I/to/shark/include -L/to/boost/lib -L/to/shark/lib -L/to/BLAS -lshark -lblas -l(boost_flags)

/to/BLAS中有一个libblas.a,我运行nm libblas.a,它给出了一行

libblas.a(ddot.o):
00000000000001c0 s EH_frame1
0000000000000000 T _ddot_

在不太安全的情况下,我假设这意味着库确实有该符号,但没有_cblas_前缀。

从这一点我能做什么?我可以更改符号名称吗?或者我需要将这个库与其他东西连接起来吗?

我用的是OS X Mavericks

提前感谢:)

OS X已经安装了BLAS(包括cblas)(它是加速框架的一部分)。没有必要下载并构建自己的。链接到-lcblas .

解决方案是由Logicrat建议的,我需要其他文件,我从这里下载了源代码,并使用cmake/make非常无缝地构建它。与由此产生的库链接解决了这个问题。