473,388 Members | 1,234 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,388 software developers and data experts.

LNK2019 Errors with Templates

Im trying out VS.NET 2003 by trying to make my own single linked list
library. Im trying to use templates but keep getting LNK2019 errors.
Right now I slimmed down my project to just the main.cpp, linked
list.cpp/h and Node.cpp/h
My error messages:
LibTest error LNK2019: unresolved external symbol "public: __thiscall
CSL::SingleLinkedList<int>::~SingleLinkedList<int> (void)"
(??1?$SingleLinkedList@H@CSL@@QAE@XZ) referenced in function _main

LibTest error LNK2019: unresolved external symbol "public: void
__thiscall CSL::SingleLinkedList<int>::Reverse(void)"
(?Reverse@?$SingleLinkedList@H@CSL@@QAEXXZ) referenced in function
_main
I posted the basics of my code at this link:
http://www.rafb.net/paste/results/OE4JNE25.html
I left out some to save space

I'm looking for any suggestions.
Nov 17 '05 #1
3 2216
Chris B wrote:
I'm looking for any suggestions.


Have you by chance put the bodies of your template class members in a .CPP
file, like you would an ordinary non-template class? If so, that's your
problem - the bodies have to be visible to the compiler in every translation
unit where the template is used. In practice this usually means that
templates are implemented entirely in the header file.

-cd
Nov 17 '05 #2
"Carl Daniel [VC++ MVP]" <cp*****************************@mvps.org.nospam > wrote in message news:<uz*************@TK2MSFTNGP11.phx.gbl>...
Chris B wrote:
I'm looking for any suggestions.


Have you by chance put the bodies of your template class members in a .CPP
file, like you would an ordinary non-template class? If so, that's your
problem - the bodies have to be visible to the compiler in every translation
unit where the template is used. In practice this usually means that
templates are implemented entirely in the header file.

-cd


Thanks! I got it too work with everything in the .h file.
Is there any way to hide the implementation so that if everything is
not in the .h file?
Nov 17 '05 #3
Chris B wrote:
Thanks! I got it too work with everything in the .h file.
Is there any way to hide the implementation so that if everything is
not in the .h file?


No, not really. some people put the implementation in another file
(frequently with the extension .ipp) and then #include that file at the end
of the header, but in the end, that's really not much different from having
the implementation in the header.

The C++ standard provides for another template model through the 'export'
keyword that does allow you to keep your template function bodies out of the
header file. Unfortunately, only one C++ compiler in existence (Comeau C++)
fully supports export. With an export-capable compiler, you still have to
ship your templates as source code if you distribute your code... but it
does get the code out of the header file.

-cd
Nov 17 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

10
by: Bil Muh | last post by:
Hello Developers, I use VC++ .NET v2003. By using Windows Forms .NET, I am developing an application which will work with TCP/IP functions. I can Build my application in Debug Mode normally, but,...
12
by: Fabio De Francesco | last post by:
Hello. I can't understand why I can't compile the following simple code, where I think I have applied all the needed rules for templates that are declared and defined in different files (*.h and...
4
by: Mastadex | last post by:
So here is my Code: template <class T> struct Nodes { T *Data; // The Image char Name; // The Name of the image Nodes<T> *Prev; Nodes<T> *Next;
2
by: rangalo | last post by:
Hi All, I have succeeded in compiling a massive project, originally from vc6 to VS .Net 2005. Now, while linking I am having loads of linker errors with the above code. LNK20019 and LNK2001....
2
by: f rom | last post by:
----- Forwarded Message ---- From: Josiah Carlson <jcarlson@uci.edu> To: f rom <etaoinbe@yahoo.com>; wxpython-users@lists.wxwidgets.org Sent: Monday, December 4, 2006 10:03:28 PM Subject: Re: ...
3
by: adina | last post by:
Hello, I have the following problem. I keep getting these linker errors, although I included all the header files and provided the right settings for the project. I use the C++ compiler in .NET...
4
by: jk2l | last post by:
Error 10 error LNK2019: unresolved external symbol __imp__glBindTexture@8 referenced in function "public: void __thiscall GLTexture::Use(void)" (?Use@GLTexture@@QAEXXZ) GLTexture.obj Error 11 error...
3
by: NorthernMonkey | last post by:
Hi, I'm new here so if anything I post is not allowed please correct it for me. I've been assigned a task of displaying a variable of unsigned int as a binary number in C++. I can do this fine...
2
by: hjazz | last post by:
Hi all, I'm new to VS, and I'm using Visual Studio .NET 2003. I'm trying to write a program which uses pcap libraries. However, I keep getting the following errors: error LNK2019: unresolved...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.