xtensor-stack / xtensor-blas

BLAS extension to xtensor
BSD 3-Clause "New" or "Revised" License
158 stars 55 forks source link

Linking error if using double type #205

Closed qustrolabe closed 3 years ago

qustrolabe commented 3 years ago

Here's simple code:

#include <iostream>
#include "xtensor/xarray.hpp"
#include "xtensor-blas/xlinalg.hpp"

using xt::xarray;
using xt::xtensor;

int main() {
  xarray<int> A = {1, 2, 3};
  xarray<int> B = {3, 4, 5};
  auto C = xt::linalg::dot(A, B);
  std::cout << C;
}

and it compiles and runs easily with:

g++ -o main main.cpp -lopenblas -llapack

But when I try to use double instead of int and compile with same command I get linker error

undefined reference to "cblas_sgemv"

However, I found that this code will link with cblas library.

g++ -o main main.cpp -lcblas -llapack

EDIT: Problem solved after recompiling OpenBLAS library. Also lapack linking is not necessary. Sorry for useless issue.