
Link Errors in VC.net that don't appear in VC 6.0
Hello Jeremiah,
I think Justin Michel can answer your question. He answered a similar post
before. For your convenience, I have included it here:
"It doesn't make any sense to export a template from a dll. You must export
an instantiation instead, but you probably don't want to do that either.
The only reason I can think of that you would definitely need to export a
template instantiation is if the instantiation is used as the base class
for another exported class. You can sidestep all these issues by keeping
all such code inline."
I hope this information is helpful.
Best regards,
Lion Shi, MCSE, MCSD
Microsoft Support Engineer
This posting is provided "AS IS" with no warranties, and confers no rights.
You assume all risk for your use. 2001 Microsoft Corporation. All rights
reserved.
--------------------
Subject: Link Errors in VC.Net that don't appear in VC 6.0
Newsgroups: microsoft.public.dotnet.languages.vc
Date: Tue, 09 Jul 2002 07:37:55 -0700
NNTP-Posting-Host: 66.129.71.26
Lines: 1
Path: cpmsftngxa07!tkmsftngp01!tkmsftngp12
Xref: cpmsftngxa07 microsoft.public.dotnet.languages.vc:11745
X-Tomcat-NG: microsoft.public.dotnet.languages.vc
This problem has me stumped, and I am inclined to think it might be a
problem with Visual Studio; however, if somebody can help me out, I'd
really appreciate it:
1) I successfully build a .DLL in VC6 containing one template class,
Box<T>.
2) I then created a second .DLL project linked to this first, which
contained two classes: Item, and Shop. Item is a simple class to store
information about any object, and Shop is a class containing as a data
member a Box<Item> object.
3) I created a simple console test application that links to both of
the above DLLs, creates a Shop object, and runs through its methods as a
test.
All of this compiles, links, and executes under Visual C++ 6.0.
However, when I bring the project into Visual C++.NET, I am getting a host
of LNK2019 errors to the tune of:
Shop.obj: error LNK 2019: unresolved external symbol
"__declspec(dllimport) public: __thiscall Box<class Item>:::Box<class
Item>(int)"
I am thinking that there is a problem with using template classes in
DLLs under VC7, because this is not the first time i've run into this
problem (in fact, this project was done as a simplification to pinpoint
problems experienced elsewhere). I know all the include and library paths
are good, dependencies are setup, and everything is included where it
should be. Like I said, all this compiles under VC6, but breaks when
imported (untouched) into VC7.
Any ideas?
-Jeremiah
**********************************************************************
Comprehensive, categorised, searchable collection of links to ASP &
ASP.NET resources...