Still trying to get a grip on Boost with some toy problems. I have a very simple program that multiplies two vectors. It worked as a single file program, but doesn't work as a multi file program. I'm finding it difficult to deal with impressive looking templates in the compiler error messages. This is on Linux, g++, Debian testing.
09-prob.h:
=======
#pragma once
#include
#include
#include
using namespace boost::numeric::ublas;
// n-vector outer product: |u>
typename vector_matrix_binary_traits >::result_type
mult_vector_vector( E1 bra, E2 ket );
09-prob.cpp:
=========
#include "09-prob.h"
template
typename vector_matrix_binary_traits >::result_type
mult_vector_vector( E1 bra, E2 ket )
{
return outer_prod(bra, ket);
}
09-driver.cpp:
==========
#include "09-prob.h"
using std::cout;
using std::endl;
int main( void )
{
using boost::numeric::ublas::vector; // Use Boost's vector, not STL's.
vector<double> u(3), v(3);
for( unsigned i = 0; i < u.size(); ++i ) {
u(i) = static_cast<double>(i);
v(i) = u(i) * u(i);
}
// Test mult_vector_vector
//
cout << mult_vector_vector(u, v) << endl;
return 0;
}
And the error message:
g++ -g3 -Wall -Wextra -Waggregate-return -Wpointer-arith -Weffc++ -Wcast-qual -Wcast-align -Wmissing-declarations -Wredundant-decls -Wwrite-strings -Winline -c -o 09-driver.o 09-driver.cpp
g++ 09-prob.o 09-driver.o -o 09-prob
09-driver.o: In function `main':
/home/p/Baruch/numla/hw1/09-driver.cpp:29: undefined reference to `boost::numeric::ublas::vector_matrix_binary_traits >, boost::numeric::ublas::vector >, boost::numeric::ublas::scalar_multiplies >::value_type, boost::numeric::ublas::vector >::value_type> >::result_type mult_vector_vector >, boost::numeric::ublas::vector > >(boost::numeric::ublas::vector >, boost::numeric::ublas::vector >)'
collect2: ld returned 1 exit status
make: *** [09-prob] Error 1
Since 09-driver.o and 09-prob.o are being linked together, I'm guessing there's something wrong with the function signature?
Can some kind soul give me a few hints on how to make this work?
Thanks!
~