Qt компиляция проекта с boost, undefined reference, ld returned exit 1 status
Доброго времени суток, Собственно ошибка:
undefined reference to `bool invertMatrix<double>
(boost::numeric::ublas::matrix<double,
boost::numeric::ublas::basic_row_major<unsigned long, long>,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >
const&, boost::numeric::ublas::matrix<double,
boost::numeric::ublas::basic_row_major<unsigned long, long>,
boost::numeric::ublas::unbounded_array<double, std::allocator<double> > >&)'
файл "utils.h":
#include <boost/numeric/ublas/matrix.hpp>
#include <boost/numeric/ublas/lu.hpp>
#include <boost/numeric/ublas/io.hpp>
// потом другие инклюды
using namespace boost::numeric::ublas;
template<typename T> bool invertMatrix(const matrix<T>& input, matrix<T>& inverse);
файл "utils.cpp"
#include "utils.h"
template<typename T> bool invertMatrix(const matrix<T>& input, matrix<T>& inverse)
{
int m = inverse.size1(), n = inverse.size2();
for (int i = 0; i < m; ++i) {
for (int j = 0; j < n; ++j) {
if (i == j) inverse(i, j) = 1.;
else inverse(i, j) =0.;
}
}
typedef permutation_matrix<std::size_t> pmatrix;
// create a working copy of the input
matrix<T> A(input);
// create a permutation matrix for the LU-factorization
pmatrix pm(A.size1());
// perform LU-factorization
int res = lu_factorize(A, pm);
if (res != 0)
return false;
// create identity matrix of "inverse"
inverse.assign(identity_matrix<T> (A.size1()));
// backsubstitute to get the inverse
lu_substitute(A, pm, inverse);
return true;
}
использую эту функцию вызывая в файле "cluster.cpp"
using namespace boost::numeric::ublas;
...
matrix<double>* S = covMatrix(b->m, points);
matrix<double> S_inv(S->size1(), S->size2());
if(! invertMatrix<double>((*S), S_inv)) return 0.0;
Наверное нужно указать флаги в .pro файле но я не знаю какие. как это исправить?
Источник: Stack Overflow на русском