Armadillo installation

流过昼夜 提交于 2019-12-13 14:30:24

问题


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

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

It always shows the error:

/tmp/ccZAE9pj.o: In 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 towrapper_dgemm_' /tmp/ccZAE9pj.o: In 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 towrapper_dgemv_' example.cpp:(.text._ZN4arma27glue_times_redirect2_helperILb1EE5applyINS_3MatIdEES4_EEvRNS3_INT_9elem_typeEEERKNS_4GlueIS5_T0_NS_10glue_timesEEE[void arma::glue_times_redirect2_helper::apply, arma::Mat >(arma::Mat::elem_type>&, arma::Glue, arma::Mat, arma::glue_times> const&)]+0x1175): undefined reference to `wrapper_dgemv_' collect2: ld returned 1 exit status

However if I add the -larmadillo option like:

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

It works by calling the old version. If I want to use new features in 3.0.1 like Mat.t(), it will also show the error:

example.cpp: In function ‘int main(int, char**)’: example.cpp:20: error: ‘struct arma::mat’ has no member named ‘t’

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

Any idea of that? Thanks.


回答1:


In the first command, you are not linking with libarmadillo. Have you considered using the -L gcc option to add a link directory ? For example:

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




回答2:


I've also run into this issue. I've fixed it by uninstalling any previous versions of Armadillo, as they can interfere with the new version.

Uninstallation can be done via your package manager. You can also manually remove the old version via the following commands (in a terminal window):

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

You'll need to run the above commands as a super-user (root). On Ubuntu it should be sufficient to preface them with "sudo".

You may also need to remove the old library files, which could be in /usr/lib/ or /usr/lib64/, or something along these lines.

Once the old version has been removed, you can re-install the new Armadillo, via the cmake based installation.




回答3:


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

make install DESTDIR=my/own/dir/

it was install incorrectly.

Hence for newbies like me, install by default makes more sense.



来源:https://stackoverflow.com/questions/10168181/armadillo-installation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!