linker errors with class

Denis Koroskin 2korden at gmail.com
Sun Oct 26 07:17:32 PDT 2008


On Sun, 26 Oct 2008 10:03:32 +0300, Mike Parker <aldacron at gmail.com> wrote:

> Michael P. wrote:
>> BCS Wrote:
>>
>>> Reply to Michael P.,
>>>
>>>> I'm getting an undefined reference error with Derelict and SDL.
>>>> I tried to create an SDLImage class, but I got an error when the files
>>>> try to link together.
>>>> I've attached the two .d files in a rar.
>>>> I compiled with "build imagetest".
>>>> I have Bud 3.04, and DMD version 1.036.
>>>> I have compiled other SDL programs, so everything is set up properly
>>>> with Derelict.
>>>> -Michael P.
>>>>
>>> what are the error messages? (copy/pates)
>>>
>>>
>>  C:\Documents and Settings\Default\My Documents\DProjects\Derelict\  
>> build imagetest
>> OPTLINK (R) for Win32  Release 8.00.1
>> Copyright (C) Digital Mars 1989-2004  All rights reserved.
>> SDLImages.obj(SDLImages)
>> Error 42: Symbol Undefined _D9SDLImages11SDL_Imagess5_dtorMFZv
>
> The linker is expecting to find a destructor for your SDLImagess class  
> in the object file, but it's not there. Your problem is on line 44 of  
> SDLImages.d:
>
> //Destructor
> ~this();
>
> Your destructor is declared, but not implemented -- hence the error. If  
> you've got nothing to do in the destructor, either implement an empty  
> one:
>
> ~this() {}
>
> Or take it out entirely, in which case the compiler will generate a  
> default destructor for you.
>
> IMO, this should really be a compiler error. I'm surprised it isn't.

No, it shouldn't. You may implement function bodies in other modules  
and/or languages (in C, for example, just make sure names have proper  
mangling).


More information about the Digitalmars-d-learn mailing list