Boost logo

Boost Users :

Subject: Re: [Boost-users] Newbie: Compiling multi filed programs
From: Steven Watanabe (watanabesj_at_[hidden])
Date: 2008-09-06 13:29:28


AMDG

Pete wrote:
> 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.
>
>
>
> <snip>
>
>
> 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?
>

Here's the problem:
In 09-driver.cpp the compiler knows that it needs
mult_vector_vector<vector<double>, vector<double> >
  but does not have its definition
In 09-prob.cpp the compiler has the definition of mult_vector_vector,
but does not know
  that it needs to be instantiated with
boost::numeric::ublas::vector<double>

You have two options:

a) put the definition of mult_vector_vector in 09-prob.h.
    This is the standard solution.
b) add the following explicit instantiation in 09-prob.cpp

typedef boost::numeric::ublas::vector<double> vec_t;
template vector_matrix_binary_traits<
    vec_t, vec_t,scalar_multiplies<vec_t::value_type, vec_t::value_type>
>::result_type
mult_vector_vector<vec_t, vec_t>( vec_t bra, vec_t ket );

In Christ,
Steven Watanabe


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net