dub, ldc2, MS VS 2015, static c library
Nicholas Wilson via digitalmars-d-ldc
digitalmars-d-ldc at puremagic.com
Fri Dec 16 00:35:06 PST 2016
On Friday, 16 December 2016 at 07:41:31 UTC, dm wrote:
> On Friday, 16 December 2016 at 07:29:29 UTC, Nicholas Wilson
> wrote:
>>>
>>> extern (C) int myFunc(int, int);
>> ^^^
>> change this to extern(C++)
>>
>> Your lib is a C++ lib and (because you didn't make myFunc
>> `extern "C"`) it has C++ name mangling (_Z6myFunciii or
>> something like it). On the D side you said it was extern(C)
>> (_myFunc) therefore the linker can't find the symbol because
>> the names don't match.
>
> Doesn't works.
> ```
> sl.obj : error LNK2019: unresolved external symbol "int __cdecl
> myFunc(int,int)" (?myFunc@@YAHHH at Z) referenced in function
> _Dmain
> .dub\build\application-release-windows-x86-ldc_0-9C4A611E39233F32B4FA0F867429B08B\sl.exe : fatal error LNK1120: 1 unresolved externals
> Error: `C:\Windows\system32\cmd.exe /s /c "C:\ldc\bin\amd64.bat
> link.exe"` failed with status: 1120
> ldc2 failed with exit code 1120.
> ```
It looks like it still can't find your function.
Whats the linker command being generated? Try running whatever
the equivalent of `nm` is on windows on sl.obj and mylib.lib and
see what the difference is?
(generally try to check with dmd before posting to the ldc, as
you're likely to get more and better help faster in learn. even
if it ldc specific you're still likely to get a faster response
if its something generic like linker error. Internal complier
errors and the like post here or submit a bug report.)
More information about the digitalmars-d-ldc
mailing list