Problem with transposition with Armadillo Library

Dear people,

I am programming a Kalman Filter and i decided to use the Armadillo library for linear algebra.
I have troubles with Matrix transposition. I can compute the transposition,
but when I want to use the result for another operation (ex: multiplication)
I can't event compile my project (I use a makefile).

Please see the code below :

The main.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
 
#include <iostream>
#include "Quaternion.h" 

using namespace std;
using namespace arma;

int main(int argCount, char **argValue) {

 fmat33 B ;
  B << 1 << 2<< 3<<endr
    << 4 << 5<< 6<<endr
    << 1 << 2<< 8<<endr;

  B.print("B vaut ;");
  
  fmat C = trans(B);
  C.print("C :"); 
  fmat D = C*B;  
//  D.print("D : ");
 return 0;
}


When I comment the line fmat D = C*B , I can compile the project.
See what happens when I comment the line:
1
2
3
4
5
6
7
8
9
10
11
es/NavMultiCap_Armadillo/bin$ make
[ 14%] Building CXX object CMakeFiles/NavMultiCap.dir/src/Kalman.cpp.o
[ 28%] Building CXX object CMakeFiles/NavMultiCap.dir/src/main.cpp.o
[ 42%] Building CXX object CMakeFiles/NavMultiCap.dir/src/MeasureStorage.cpp.o
[ 57%] Building CXX object CMakeFiles/NavMultiCap.dir/src/Quaternion.cpp.o
[ 71%] Building CXX object CMakeFiles/NavMultiCap.dir/src/Sensor.cpp.o
[ 85%] Building CXX object CMakeFiles/NavMultiCap.dir/src/StateModel.cpp.o
[100%] Building CXX object CMakeFiles/NavMultiCap.dir/src/StateVector.cpp.o
Linking CXX executable NavMultiCap
[100%] Built target NavMultiCap
emin3m@emin3m-laptop:/media/347C31257C30E2F2/Base/Codes_CMD/Kalman_Fusion/branches/NavMultiCap_Armadillo/bin$ 



But if I uncomment it I have this error from the shell :
1
2
3
4
5
6
7
8
9
10
11
12
/NavMultiCap_Armadillo/bin$ make
Scanning dependencies of target NavMultiCap
[ 14%] Building CXX object CMakeFiles/NavMultiCap.dir/src/main.cpp.o
Linking CXX executable NavMultiCap
CMakeFiles/NavMultiCap.dir/src/main.cpp.o: In function `void arma::atlas::cblas_gemv<float>(CBLAS_ORDER, CBLAS_TRANSPOSE, int, int, float, float const*, int, float const*, int, float, float*, int)':
main.cpp:(.text._ZN4arma5atlas10cblas_gemvIfEEv11CBLAS_ORDER15CBLAS_TRANSPOSEiiT_PKS4_iS6_iS4_PS4_i[void arma::atlas::cblas_gemv<float>(CBLAS_ORDER, CBLAS_TRANSPOSE, int, int, float, float const*, int, float const*, int, float, float*, int)]+0x6f): undefined reference to `wrapper_cblas_sgemv'
CMakeFiles/NavMultiCap.dir/src/main.cpp.o: In function `void arma::atlas::cblas_gemm<float>(CBLAS_ORDER, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, int, int, int, float, float const*, int, float const*, int, float, float*, int)':
main.cpp:(.text._ZN4arma5atlas10cblas_gemmIfEEv11CBLAS_ORDER15CBLAS_TRANSPOSES3_iiiT_PKS4_iS6_iS4_PS4_i[void arma::atlas::cblas_gemm<float>(CBLAS_ORDER, CBLAS_TRANSPOSE, CBLAS_TRANSPOSE, int, int, int, float, float const*, int, float const*, int, float, float*, int)]+0x7d): undefined reference to `wrapper_cblas_sgemm'
collect2: ld returned 1 exit status
make[2]: *** [NavMultiCap] Erreur 1
make[1]: *** [CMakeFiles/NavMultiCap.dir/all] Erreur 2
make: *** [all] Erreur 2


Could you help me to solve this problem ?
I was using the library Eigen before and everything was
fine, until my colleagues "forced" my to use Armadillo...
for better compatibility.

Thank you
An undefined reference of this kind means that a required library is not being searched.

Are you missing an -larmadillo compiler/linker option?
Hello,

Yes it was a problem concerning linking to Lapack and BLAS. My compiled Armadillo library was not the folder "/usr/" so I had problem of dependencies wih the Lapack and blas.

Solution : I added the compiled armadillo library to the folder "/usr/" and I also added the following line to my CMakeList.txt file:
set(Armadillo_DIR "/usr/share/Armadillo/CMake/")

So my CMakeLists.txt finally looks like :
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# Ajustez en fonction de votre version de CMake
cmake_minimum_required (VERSION 2.8)

# Nom du projet
project (NavMultiCap)

set(Armadillo_DIR "/usr/share/Armadillo/CMake/") 
find_package (Armadillo REQUIRED)

include_directories(${ARMADILLO_INCLUDE_DIR})

#Configuration de l'exécutable
file(
        GLOB_RECURSE
        source_files
        src/*
)

add_executable(
	NavMultiCap
	 ${source_files}
)

# Hello sera linké avec les bibliothèques d'OpenCV

target_link_libraries (NavMultiCap ${Armadillo_LIBS}) */

Now everything works perfectly.
Topic archived. No new replies allowed.