Install Armadillo

Hi, I installed Armadillo3.0.1 in my working directory / home / me / package / armadillo 3.0.1 /, as README.txt said. But when I try the example:

g ++ -I / home / me / package / armadillo3.0.1 / usr / include / example.cpp -o example -O1

It always shows an error:

/tmp/ccZAE9pj.o: In the void arma::gemm<false, false, false, false>::apply_blas_type<double>(arma::Mat<double>&, arma::Mat<double> const&, arma::Mat<double> const&, double, double)': example.cpp:(.text._ZN4arma4gemmILb0ELb0ELb0ELb0EE15apply_blas_typeIdEEvRNS_3MatIT_EERKS5_S8_S4_S4_[void arma::gemm<false, false, false, false>::apply_blas_type<double>(arma::Mat<double>&, arma::Mat<double> const&, arma::Mat<double> const&, double, double)]+0x75e): undefined reference to function void arma::gemm<false, false, false, false>::apply_blas_type<double>(arma::Mat<double>&, arma::Mat<double> const&, arma::Mat<double> const&, double, double)': example.cpp:(.text._ZN4arma4gemmILb0ELb0ELb0ELb0EE15apply_blas_typeIdEEvRNS_3MatIT_EERKS5_S8_S4_S4_[void arma::gemm<false, false, false, false>::apply_blas_type<double>(arma::Mat<double>&, arma::Mat<double> const&, arma::Mat<double> const&, double, double)]+0x75e): undefined reference to wrapper_dgemm_ '/ tmp / ccZAE 9pj.o: In the void arma::glue_times_redirect2_helper<true>::apply<arma::Mat<double>, arma::Mat<double> >(arma::Mat<arma::Mat<double>::elem_type>&, arma::Glue<arma::Mat<double>, arma::Mat<double>, arma::glue_times> const&)': example.cpp:(.text._ZN4arma27glue_times_redirect2_helperILb1EE5applyINS_3MatIdEES4_EEvRNS3_INT_9elem_typeEEERKNS_4GlueIS5_T0_NS_10glue_timesEEE[void arma::glue_times_redirect2_helper<true>::apply<arma::Mat<double>, arma::Mat<double> >(arma::Mat<arma::Mat<double>::elem_type>&, arma::Glue<arma::Mat<double>, arma::Mat<double>, arma::glue_times> const&)]+0xe69): undefined reference to function void arma::glue_times_redirect2_helper<true>::apply<arma::Mat<double>, arma::Mat<double> >(arma::Mat<arma::Mat<double>::elem_type>&, arma::Glue<arma::Mat<double>, arma::Mat<double>, arma::glue_times> const&)': example.cpp:(.text._ZN4arma27glue_times_redirect2_helperILb1EE5applyINS_3MatIdEES4_EEvRNS3_INT_9elem_typeEEERKNS_4GlueIS5_T0_NS_10glue_timesEEE[void arma::glue_times_redirect2_helper<true>::apply<arma::Mat<double>, arma::Mat<double> >(arma::Mat<arma::Mat<double>::elem_type>&, arma::Glue<arma::Mat<double>, arma::Mat<double>, arma::glue_times> const&)]+0xe69): undefined reference to void arma::glue_times_redirect2_helper<true>::apply<arma::Mat<double>, arma::Mat<double> >(arma::Mat<arma::Mat<double>::elem_type>&, arma::Glue<arma::Mat<double>, arma::Mat<double>, arma::glue_times> const&)': example.cpp:(.text._ZN4arma27glue_times_redirect2_helperILb1EE5applyINS_3MatIdEES4_EEvRNS3_INT_9elem_typeEEERKNS_4GlueIS5_T0_NS_10glue_timesEEE[void arma::glue_times_redirect2_helper<true>::apply<arma::Mat<double>, arma::Mat<double> >(arma::Mat<arma::Mat<double>::elem_type>&, arma::Glue<arma::Mat<double>, arma::Mat<double>, arma::glue_times> const&)]+0xe69): undefined reference to wrapper_dgemv_ 'example.cpp :(. text._ZN4arma27glue_times_redirect2_helperILb1EE5applyINS_3MatIdEES4_EEvRNS3_INT_9elem_typeEEERKNS_4GlueIS5_T0_NS_10glue_timesEEE [], Matte :: Armey & Armey :: Armey & Armey :: Arme & Armeype> Matte & ArpememperaMe & Arme :: Arpemelem_permemelem 0x1175): undefined reference to `wrapper_dgemv_ 'collect2: ld returned 1 exit status

However, if I add the -larmadillo option, for example:

g ++ example.cpp -o example -O1 -larmadillo

It works by invoking the old version. If I want to use new functions in version 3.0.1, such as Mat.t (), it will also show an error:

example.cpp: In the function 'int main (int, char **): example.cpp: 20: error:' struct arma :: mat does not have a name named 't

This shows that by adding -larmadillo, it calls the old version of armadillo from / usr / include / armadillo _bits /.

Any idea? Thanks.

+2
source share
3 answers

In the first command, you do not contact libarmadillo. Do you consider using the -L gcc option to add a link directory? For instance:

g ++ -I / home / me / package / armadillo3.0.1 / usr / include / -L / home / me / package / armadillo3.0.1 / usr / lib example.cpp -o example -O1 -larmadillo

+1
source

I also ran into this problem. I fixed it by deleting any previous versions of Armadillo, as they may interfere with the new version.

Uninstallation can be done through the package manager. You can also manually delete the old version using the following commands (in the terminal window):

  rm /usr/include/armadillo rm -rf /usr/include/armadillo_bits 

You will need to run the above commands as root (root). On Ubuntu, it should be enough for the preface to be "sudo".

You may also need to delete old library files, which might be in / usr / lib / or / usr / lib64 / or something like that.

Once the old version is removed, you can reinstall the new Armadillo through the cmake-based installation.

0
source

I deleted the old one and reinstalled the new one in the default directory. It worked! It seems so when I installed the old version with:

make installation DESTDIR = my / own / dir /

It was installed incorrectly.

Therefore, for beginners like me, the default setting makes more sense.

0
source

Source: https://habr.com/ru/post/1485772/


All Articles