Click here to Skip to main content
16,006,442 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: how do I derive a class from a template class? Pin
Chad Koehler20-Jun-02 5:15
Chad Koehler20-Jun-02 5:15 
GeneralRe: how do I derive a class from a template class? Pin
Niklas L25-Jun-02 1:57
Niklas L25-Jun-02 1:57 
QuestionAbout CDex? Pin
chen19-Jun-02 23:13
chen19-Jun-02 23:13 
GeneralIdle Time Out. Pin
19-Jun-02 23:08
suss19-Jun-02 23:08 
GeneralRe: Idle Time Out. Pin
19-Jun-02 23:38
suss19-Jun-02 23:38 
GeneralRe: Idle Time Out. Pin
vijayaramaraju20-Jun-02 0:16
vijayaramaraju20-Jun-02 0:16 
GeneralRe: Idle Time Out. Pin
20-Jun-02 2:08
suss20-Jun-02 2:08 
Question[long] VC7 : do you prefer LNK2005 or LNK2019 ? Pin
19-Jun-02 22:49
suss19-Jun-02 22:49 
I did post a few weeks ago about a LNK2005 error with VC7 (no error on VC6 with same code)
and did not get any satisfying anwer. Now I am able to tell you more on the subject, which
seems to be a mixed template / dll export problem.

Let's say I have a MFC project with one EXE (crystal.exe) and one DLL (dutils.dll).

In the DLL, I have one class derived from CString (over simplified for the demonstration) :

////////////////////////////////////////////////////
// DCString.h
#ifdef DUTILS_IMPL
#define CLASS_DUTILS __declspec(dllexport)
#else
#define CLASS_DUTILS __declspec(dllimport)
#endif

class CLASS_DUTILS DCString : public CString
{
public:
DCString();
CString ToUpper();

};
/////////////////////////////////////////////////////
(NB : CString in a MFC7 project is now template-derived and defined as :
CStringT<TCHAR, StrTraitMFC<TCHAR, ChTraitsCRT<TCHAR>>>)

Now somewhere in my application EXE (here in DCAcquisitionHolder.cpp), if I include this file :
#include "DCString.h"

--> Cry | :(( I get this error (multiple times , roughly once / DCString function) :

DUtilsd.lib(DUtilsd.dll) : error LNK2005:
"public: __thiscall ATL::CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> > >::
CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> > >
(class ATL::CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> > > const &)"
(??0?$CStringT@DV?$StrTraitMFC@DV?$ChTraitsCRT@D@ATL@@@@@ATL@@QAE@ABV01@@Z)
already defined in DCAcquisitionHolder.obj


--> if I declare my DCString class like this :

///////////////////////////
class DCString public CString // no __declspec(dllexport) or __declspec(dllimport)
{
(...)
}
///////////////////////////

Of course Cry | :(( I have an error like this (class is not exported) :

DCAnalysis.obj : error LNK2019: unresolved external symbol
"public: class ATL::CStringT<char,class StrTraitMFC<char,class ATL::ChTraitsCRT<char> > >
__thiscall DCString::ToUpper(void)" (... etc...)

Do you have any idea how I could combine a correct export of the class with no double definition ?

Many many thanks for your help.
GeneralLoad old version project problem Pin
19-Jun-02 22:42
suss19-Jun-02 22:42 
QuestionHow to get the handle of a running program in another program? Pin
Kiddxin19-Jun-02 22:26
Kiddxin19-Jun-02 22:26 
AnswerRe: How to get the handle of a running program in another program? Pin
19-Jun-02 22:52
suss19-Jun-02 22:52 
GeneralRe: How to get the handle of a running program in another program? Pin
Kiddxin20-Jun-02 17:46
Kiddxin20-Jun-02 17:46 
GeneralIsapi concurrency requests Pin
19-Jun-02 21:51
suss19-Jun-02 21:51 
Generalsetting DTR serial port pin on and checking DSR Pin
19-Jun-02 21:44
suss19-Jun-02 21:44 
GeneralRe: setting DTR serial port pin on and checking DSR Pin
19-Jun-02 22:02
suss19-Jun-02 22:02 
GeneralRe: setting DTR serial port pin on and checking DSR Pin
19-Jun-02 22:45
suss19-Jun-02 22:45 
GeneralLIB - what and how Pin
Gennady Oster19-Jun-02 21:19
Gennady Oster19-Jun-02 21:19 
GeneralRe: LIB - what and how Pin
Nish Nishant19-Jun-02 21:47
sitebuilderNish Nishant19-Jun-02 21:47 
GeneralRe: LIB - what and how Pin
Gennady Oster19-Jun-02 22:08
Gennady Oster19-Jun-02 22:08 
GeneralRe: LIB - what and how Pin
Mike Nordell20-Jun-02 0:26
Mike Nordell20-Jun-02 0:26 
Questionhow to use windows 2000 programming in windows 98 ? Pin
19-Jun-02 19:29
suss19-Jun-02 19:29 
AnswerRe: how to use windows 2000 programming in windows 98 ? Pin
Nish Nishant19-Jun-02 19:47
sitebuilderNish Nishant19-Jun-02 19:47 
AnswerRe: how to use windows 2000 programming in windows 98 ? Pin
KarstenK20-Jun-02 0:00
mveKarstenK20-Jun-02 0:00 
GeneralMoving Display Pin
Sam197919-Jun-02 19:03
Sam197919-Jun-02 19:03 
GeneralRe: Moving Display Pin
Prem Kumar19-Jun-02 20:29
Prem Kumar19-Jun-02 20:29 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.