2

I am using the armadillo library inside a package (LAMMPS package). I also used Armadillo to compile different codes, and it works fines, and I use the following compiling command:

g++ example2.cpp -o example2 -O3 -larmadillo -DARMA_DONT_USE_WRAPPER -lblas -llapack

Armadillo works fine for matrix storage and loading inside the package, however, when it comes to matrix-vector multiplication, it gives me the following error:

/usr/include/armadillo_bits/wrapper_blas.hpp:42: undefined reference to `dgemv_'

Any suggestion on how to go around it?

  • Why are you setting "ARMA_DONT_USE_WRAPPER" and still linking with armadillo? You define that wrapper if you want to link directly with blas and lapack or you dont define that wrapper and link with only armadillo. Try `g++ example2.cpp -o example2 -O3 -DARMA_DONT_USE_WRAPPER -lblas -llapack` ` – darcamo May 25 '20 at 13:32
  • I am not an expert in compiling stuff but with or without `-DARMA_DONT_USE_WRAPPER` I get the same error for my lammps package, but in both cases, example2.cpp get compiled. Without it LAMMPS produces the following error `undefined reference to `wrapper_dgemv_'`. – Alireza Moradzadeh May 25 '20 at 21:14
  • Undefined reference means that the linker did not find the implementation of some function (that was properly declared in some header file you included, otherwise it would fail during compilation). The `dgemv` function comes from lapack and performs matrix-vector multiplication. It seems that armadillo creates a wrapper for it, but the linker does not find this wrapper. You can try `g++ example2.cpp -o example2 -O3 -larmadillo -DARMA_DONT_USE_WRAPPER` instead. If that does not work then we will need more information (how was armadillo installed? What is your system? etc) – darcamo May 25 '20 at 21:32
  • There is something that I should clarify. The example2 gets compiled and it is fully functional. In other words, example2 executes properly. – Alireza Moradzadeh May 26 '20 at 00:31
  • The problem occurs when I use armadillo inside the LAMMPS package, https://lammps.sandia.gov/doc/Manual.html. Inside Makefile I add `-larmadillo -DARMA_DONT_USE_WRAPPER -lblas -llapack`, then whenever I have matrix-vector multiplication it does not work. When I remove matrix vector multiplication, it works fine. I replaced the matrix-vector multiplication with vector-scalar multiplication. It is now working but its performance is slow, but better than for loop over each element. – Alireza Moradzadeh May 26 '20 at 00:31

0 Answers0