Solved

error: "template function has already been defined"

Posted on 1998-04-04
3
919 Views
Last Modified: 2008-02-01
Hi there,

This is probably a very easy question, but I'm a little confused over it.  I've been living in the land of Delphi for the past 4 years and have let my C++ experience slip.  I'm just now getting back into this area and hit a wall.  I'm not sure if this problem is compiler specific or a mis-understanding of C++ on my part.

I recently got a library and am trying to use it under MSVC++ 5.0.  The company I got it from says that it is supposed to work fine in this environment.  But whenever I try to compile it, I get an error (in a lot of different places) that says "template function has already been defined".  It proceeds to tell me which one is duplicated.

Is there some sort of setting in MSVC that allows me to work with these object templates?  

Thanks,
joe
0
Comment
Question by:greendot
3 Comments
 
LVL 5

Expert Comment

by:yonat
ID: 1184055
Sounds like you're including the same header twice (and therefore the function definition is repeated). If this is the case, just add include guards (in VC5 you can use "#pragma once" for that). Otherwise, please post the offending code.
0
 

Expert Comment

by:jann
ID: 1184056
Also check the library you used, does it use MFC library also?  If it does, it should use the shared MFC library.
0
 

Accepted Solution

by:
greendot2 earned 50 total points
ID: 1184057
I dug the "service release 3" out of my MSDN CD stack and now things are working fine.  Too bad I never saw that before.

greendot
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In days of old, returning something by value from a function in C++ was necessarily avoided because it would, invariably, involve one or even two copies of the object being created and potentially costly calls to a copy-constructor and destructor. A…
What is C++ STL?: STL stands for Standard Template Library and is a part of standard C++ libraries. It contains many useful data structures (containers) and algorithms, which can spare you a lot of the time. Today we will look at the STL Vector. …
The goal of the video will be to teach the user the difference and consequence of passing data by value vs passing data by reference in C++. An example of passing data by value as well as an example of passing data by reference will be be given. Bot…
The viewer will be introduced to the technique of using vectors in C++. The video will cover how to define a vector, store values in the vector and retrieve data from the values stored in the vector.

863 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now