win64 - win32.oaidl.VARIANT -> error LNK2019

Vladimir Panteleev via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Fri Oct 31 09:05:07 PDT 2014


On Friday, 31 October 2014 at 15:56:54 UTC, deed wrote:
> // bindings from 
> https://github.com/CS-svnmirror/dsource-bindings-win32/blob/308739a417eaaba85a5d3ce7741fd43d3042efe0/oaidl.d
>
> ---
> import win32.oaidl;
>
> // The following gives linker error: error LNK2019: unresolved 
> external
> // symbol _D5win325oaidl7VARIANT6__initZ referenced
> // in function ...
> VARIANT v;
> v.vt = VARENUM.VT_I4;
> v.lVal = 1;
>
> // while this works - no linker error
> VARIANT v = { vt: VARENUM.VT_I4, lVal: 1 };
>
>
> Defining a similar structure as VARIANT with anonymous structs 
> and unions targeting linux seemed to work fine without linker 
> problems. What is the idiomatic way of handling this on win64?

Your link is failing because the .init value of the struct is not 
found. The .init will be in the object file corresponding to the 
module where the struct is defined, so to fix the linker error, 
add the win32.oaidl module to the list of modules you're 
compiling and linking. An easy way to do that is to use rdmd 
instead of dmd to build your program.


More information about the Digitalmars-d-learn mailing list