Undefined function, even though imported
Mafi
mafi at example.org
Mon Jun 13 14:30:24 PDT 2011
Am 13.06.2011 23:18, schrieb Loopback:
> Hi!
>
> Let me begin by saying, I'm sorry if this is caused of some obvious
> error but since I am new to D, I am not aware of all the tricks and
> treats it offers.
>
> I am working with the WindowsAPI binding at dsource.org (though I do not
> believe this is related to the binding itself). However, in my code I
> call the function LOWORD (win32 specific). This function is defined in
> the win32.windef module. Although it is defined there (without any
> encapsulations in version statements or anything similar) I receive this
> error:
>
> Error 42: Symbol Undefined _D5win326windef6LOWORDFkZt (LOWORD undefined)
>
> To solve this I had to copy-paste the exact function directly into my
> own file/module instead. So my question is the following; why do I have
> to copy and paste the function directly in my code when it is clearly
> defined in one of the files I import?
>
> Windef.d attached
Your error is an linker error. This means the last step of creating an
exceutable couldn't be taken: finding all names you promised to be there.
When you, import a module, you promise: "Compiler, I know that
definitions I'm using in this module aren't declared in there, but look
at this module. I promise that all these functions in there will be
there during the linking process". The compiler gives no error because
you promised, but now the linker has problem: It hasn't got the
defintions you said to be there. You have to say the linker where to
find them.
One way is to give your .d/.lib file to dmd so he can give it to the linker:
dmd main.d path/to/windef.d
Mafi
More information about the Digitalmars-d-learn
mailing list