3

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.

zhh210
  • 388
  • 4
  • 12

3 Answers3

2

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

Samuel Gosselin
  • 591
  • 5
  • 5
  • 1
    Thanks, it seems work. Now it doesn't print out arcane errors but only complaining cannot find libmkl.so. – zhh210 Apr 16 '12 at 05:32
  • You probably need a similar -L and -l for libmkl. – emsr Apr 16 '12 at 20:34
  • I've ran into a similar problem. I installed armadillo without root permissions and I guess I need to tell g++ where headers and the library are. Therefore, I've done the following: g++ -std=c++0x example.cpp -o example -O2 -I/my_directory/armadillo-9.100.5/include -L/my_directory/armadillo-9.100.5/libarmadillo.so.9.100.5 -lblas -llapack Now, for some reason I don't understand if I add the -larmadillo option to include the run-time library, I get an error telling that -larmadillo couldn't be found. Any ideas what might be wrong? Thanks in advance! – Sergio Cobo Oct 16 '18 at 19:50
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.

mtall
  • 3,574
  • 15
  • 23
0

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.

zhh210
  • 388
  • 4
  • 12