Re: LNK2001: unresolved external



See inline...

"Jon Evans" <JonEvans@xxxxxxxxxxxxxxxxxxxxxxxxx> wrote in message
news:EE351310-20C8-4E8B-90B9-F8582031AD56@xxxxxxxxxxxxxxxx
>
>
> "www.fruitfruit.com" wrote:
>
>> A SMALL piece of code may help us understand your problem better.
>>
>>
>
> Well, :-
>
> Header file :-
>
> class MyClass
> {
> MyClass() ;
> virtual ~MyClass() ;
> } ;
>
> C file
>
> #include "MyClass.h"
> MyClass()
> {
> }
>
> ~MyClass()
> {
> }
off the top of my head, I'd say:
MyClass::MyClass(void)
{
}

MyClass::~MyClass(void)
{
}

>
> These are in a MFC extension DLL. The DLL builds find both debug functions
> and release functions.
>
> Now create a seperate test app - it does not use MyClass directly, it uses
> another class who contains a (protected) member variable of type
> MyClass().
>
> The test app compiles and runs perfectly in debug mode. However it refuses
> to link, claiming that it cant find CMyClass's destructor.
>
> Strip out the destructor from the original CPP and move it to the header
> :-
>
> class MyClass
> {
> MyClass() ;
> virtual ~MyClass() { } ; // <---------
> } ;
>
> Now the release build of the test app compiles and runs perfectly.
>
> Add a dozen more functions (that also get called) to this class and the
> linker will still find them, it just seems to have a bit of a "thing" with
> destructors.
>
> If I now derive CMyClass from CObject, it'll fail to compile again in
> exactly the same way but one of the Cobject-related functions is now
> missing.
>
> This must be a symptom of something wrong else where, but I can't think
> what. Incidently the DLL has dozens of classes (some exported, some not)
> and
> it's happy with them, it's only if I now add any new classes that the
> problem
> occurs.
>
> TTFN,
> Jon
>
>
>


.



Relevant Pages

  • Re: Is it good programming to set instance in class without using C-tor
    ... I have a class definition called MyClass see below. ... I create an instance of this class MyClass ... the question of what arguments should go on the constructor is ... your client has to test before they try to use an object instance. ...
    (microsoft.public.dotnet.languages.csharp)
  • Re: LNK2001: unresolved external
    ... Header file:- ... class MyClass ... MyClass() ... Strip out the destructor from the original CPP and move it to the header:- ...
    (microsoft.public.vc.mfc)
  • Re: Is there anyway to forward reference a namespace like STL?
    ... class MyClass; ... class AnotherClass ... This way I do not need to include the header to MyClass in the header for AnotherClass. ...
    (microsoft.public.vc.language)
  • Re: Object creation overhead
    ... > class MyClass ... This is, of course, over and above the memory required for the ... > 'MyClass' objects themselves. ... > The 'proxy' class approach won't see a reduction in the number of ...
    (comp.lang.java)
  • Re: Changed class
    ... public int value1=0; ... private int oldvalue1=0; ... MyClass nn = new MyClass ... Class MyClass {public int value1=0; ...
    (microsoft.public.dotnet.languages.csharp)