dub, ldc2, MS VS 2015, static c library

dm via digitalmars-d-ldc digitalmars-d-ldc at puremagic.com
Thu Dec 15 23:41:31 PST 2016


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.
```


More information about the digitalmars-d-ldc mailing list