One possible subtle problem involves the compiler's default behavior in including files having template code. By default, if a template is declared in a header file and is used, the compiler looks for a corresponding .cc (or .cpp, .C, etc) file, and includes it automatically. If the source code was not written with automatic inclusion in mind, you can get duplicate definition errors due to multiple inclusion of the same file.
First, check for something odd like the above. If that's not the problem, try adding the option
% cat foo.cc #include <algorithm> % CC -E foo.cc > algo.h # don't do this! % cat myproject.cc #include "algo.h" // don't do this ...