Thread overview | |||||||
---|---|---|---|---|---|---|---|
|
November 01, 2017 Link errors when compiling shared lib on windows | ||||
---|---|---|---|---|
| ||||
I am following this short tutorial on compiling a shared lib: https://wiki.dlang.org/Call_D_from_Ruby_using_FFI Because it's on Windows I am using these compiler options: -shared -m64 -defaultlib=libphobos2.so i.d However, I am receiving rather a lot of linker errors. Not sure what else to provide the compiler. i.obj : error LNK2019: unresolved external symbol _D3std5stdio4File17LockingTextWriter6__dtorMFNeZv referenced in function _D3std5stdio16__T7writelnTAyaZ7writelnFNfAyaZv i.obj : error LNK2019: unresolved external symbol _D3std9exception14ErrnoException6__ctorMFNeAyaAyamZC3std9exception14ErrnoException referenced in function _D3std9exception135__T12errnoEnforceTiVAyaa50_633a5c445c646d64325c77696e646f77735c62696e5c2e2e5c2e2e5c7372635c70686f626f735c7374645c737464696f2e64Vmi2776Z12errnoEnforceFNfiLAyaZi i.obj : error LNK2019: unresolved external symbol _D3std3utf12UTFException7__ClassZ referenced in function _D3std3utf98__T13_utfExceptionVE3std8typecons55__T4FlagVAyaa19_7573655265706c6163656d656e744463686172Z4Flagi0Z13_utfExceptionFNaNfAyawZw i.obj : error LNK2019: unresolved external symbol _d_assert_msg referenced in function _D3std5stdio4File17LockingTextWriter12__T3putTAyaZ3putMFNfAyaZv i.obj : error LNK2019: unresolved external symbol _D3std9exception14ErrnoException7__ClassZ referenced in function _D3std9exception135__T12errnoEnforceTiVAyaa50_633a5c445c646d64325c77696e646f77735c62696e5c2e2e5c2e2e5c7372635c70686f626f735c7374645c737464696f2e64Vmi2776Z12errnoEnforceFNfiLAyaZi i.obj : error LNK2019: unresolved external symbol _fputc_nolock referenced in function _D3std5stdio4File17LockingTextWriter10__T3putTwZ3putMFNfwZ12trustedFPUTCFNbNiNeiPS4core4stdc5stdio6_iobufZi i.obj : error LNK2019: unresolved external symbol fwrite referenced in function _D3std5stdio21__T13trustedFwriteTaZ13trustedFwriteFNbNiNePOS4core4stdc5stdio6_iobufxAaZm i.obj : error LNK2019: unresolved external symbol _D3std5stdio4File6__dtorMFNfZv referenced in function _D3std5stdio16__T7writelnTAyaZ7writelnFNfAyaZv i.obj : error LNK2019: unresolved external symbol _d_throwc referenced in function _D3std9exception135__T12errnoEnforceTiVAyaa50_633a5c445c646d64325c77696e646f77735c62696e5c2e2e5c2e2e5c7372635c70686f626f735c7374645c737464696f2e64Vmi2776Z12errnoEnforceFNfiLAyaZi i.obj : error LNK2019: unresolved external symbol _D3std5stdio4File17LockingTextWriter7handle_MFNdNeZPS4core4stdc5stdio6_iobuf referenced in function _D3std5stdio4File17LockingTextWriter10__T3putTwZ3putMFNfwZv i.obj : error LNK2019: unresolved external symbol _d_newclass referenced in function _D3std9exception135__T12errnoEnforceTiVAyaa50_633a5c445c646d64325c77696e646f77735c62696e5c2e2e5c2e2e5c7372635c70686f626f735c7374645c737464696f2e64Vmi2776Z12errnoEnforceFNfiLAyaZi i.obj : error LNK2019: unresolved external symbol _d_assertp referenced in function _D3std5stdio4File17LockingTextWriter10__T3putTwZ3putMFNfwZv i.obj : error LNK2019: unresolved external symbol _d_arrayboundsp referenced in function _D3std5stdio4File17LockingTextWriter10__T3putTwZ3putMFNfwZv i.obj : error LNK2019: unresolved external symbol _D3std5stdio13trustedStdoutFNdNeZS3std5stdio4File referenced in function _D3std5stdio16__T7writelnTAyaZ7writelnFNfAyaZv i.obj : error LNK2019: unresolved external symbol _D3std5stdio4File17lockingTextWriterMFNfZS3std5stdio4File17LockingTextWriter referenced in function _D3std5stdio16__T7writelnTAyaZ7writelnFNfAyaZv i.obj : error LNK2019: unresolved external symbol _D3std3utf12isValidDcharFNaNbNiNfwZb referenced in function _D3std5stdio4File17LockingTextWriter10__T3putTwZ3putMFNfwZv i.obj : error LNK2019: unresolved external symbol _aApplycd1 referenced in function _D3std5stdio4File17LockingTextWriter12__T3putTAyaZ3putMFNfAyaZv i.obj : error LNK2019: unresolved external symbol _D3std3utf12UTFException6__ctorMFNaNbNiNfAyaAyamC6object9ThrowableZC3std3utf12UTFException referenced in function _D3std3utf98__T13_utfExceptionVE3std8typecons55__T4FlagVAyaa19_7573655265706c6163656d656e744463686172Z4Flagi0Z13_utfExceptionFNaNfAyawZw i.obj : error LNK2019: unresolved external symbol _fputwc_nolock referenced in function _D3std5stdio4File17LockingTextWriter10__T3putTwZ3putMFNfwZ13trustedFPUTWCFNbNiNeiPS4core4stdc5stdio6_iobufZi LINK : error LNK2001: unresolved external symbol _DllMainCRTStartup i.dll : fatal error LNK1120: 20 unresolved externals Error: linker exited with status 1120 |
November 01, 2017 Re: Link errors when compiling shared lib on windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Fitzpatrick | On Wednesday, 1 November 2017 at 15:15:27 UTC, Daniel Fitzpatrick wrote:
> I am following this short tutorial on compiling a shared lib:
>
> https://wiki.dlang.org/Call_D_from_Ruby_using_FFI
>
> Because it's on Windows I am using these compiler options:
>
> -shared -m64 -defaultlib=libphobos2.so i.d
>
>
> However, I am receiving rather a lot of linker errors. Not sure what else to provide the compiler.
Try less, especially no `-defaultlib` overridden with a Linux shared-object. You'll have to edit the hardcoded `./i.so` in the example as well obviously.
|
November 01, 2017 Re: Link errors when compiling shared lib on windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to kinke | On Wednesday, 1 November 2017 at 15:52:17 UTC, kinke wrote: > On Wednesday, 1 November 2017 at 15:15:27 UTC, Daniel Fitzpatrick wrote: >> I am following this short tutorial on compiling a shared lib: >> >> https://wiki.dlang.org/Call_D_from_Ruby_using_FFI >> >> Because it's on Windows I am using these compiler options: >> >> -shared -m64 -defaultlib=libphobos2.so i.d >> >> >> However, I am receiving rather a lot of linker errors. Not sure what else to provide the compiler. > > Try less, especially no `-defaultlib` overridden with a Linux shared-object. You'll have to edit the hardcoded `./i.so` in the example as well obviously. Oops, missed that! What i've tried is -shared -m64 i.d -shared -m64 -defaultlib=libphobos2.dll i.d Still seeing a lot of linker errors. Errors for the former: i.obj : error LNK2019: unresolved external symbol _D3std5stdio13trustedStdoutFNdNeZS3std5stdio4File referenced in function _D3std5stdio16__T7writelnTAyaZ7writelnFNfAyaZv i.obj : error LNK2019: unresolved external symbol _D3std5stdio4File17lockingTextWriterMFNfZS3std5stdio4File17LockingTextWriter referenced in function _D3std5stdio16__T7writelnTAyaZ7writelnFNfAyaZv i.obj : error LNK2019: unresolved external symbol _D3std3utf12isValidDcharFNaNbNiNfwZb referenced in function _D3std5stdio4File17LockingTextWriter10__T3putTwZ3putMFNfwZv i.obj : error LNK2019: unresolved external symbol _d_assert_msg referenced in function _D3std5stdio4File17LockingTextWriter12__T3putTAyaZ3putMFNfAyaZv i.obj : error LNK2019: unresolved external symbol _aApplycd1 referenced in function _D3std5stdio4File17LockingTextWriter12__T3putTAyaZ3putMFNfAyaZv i.obj : error LNK2019: unresolved external symbol _D3std3utf12UTFException6__ctorMFNaNbNiNfAyaAyamC6object9ThrowableZC3std3utf12UTFException referenced in function _D3std3utf98__T13_utfExceptionVE3std8typecons55__T4FlagVAyaa19_7573655265706c6163656d656e744463686172Z4Flagi0Z13_utfExceptionFNaNfAyawZw i.obj : error LNK2019: unresolved external symbol _fputwc_nolock referenced in function _D3std5stdio4File17LockingTextWriter10__T3putTwZ3putMFNfwZ13trustedFPUTWCFNbNiNeiPS4core4stdc5stdio6_iobufZi i.obj : error LNK2019: unresolved external symbol _d_throwc referenced in function _D3std9exception135__T12errnoEnforceTiVAyaa50_633a5c445c646d64325c77696e646f77735c62696e5c2e2e5c2e2e5c7372635c70686f626f735c7374645c737464696f2e64Vmi2776Z12errnoEnforceFNfiLAyaZi i.obj : error LNK2019: unresolved external symbol _D3std5stdio4File17LockingTextWriter6__dtorMFNeZv referenced in function _D3std5stdio16__T7writelnTAyaZ7writelnFNfAyaZv i.obj : error LNK2019: unresolved external symbol _D3std9exception14ErrnoException6__ctorMFNeAyaAyamZC3std9exception14ErrnoException referenced in function _D3std9exception135__T12errnoEnforceTiVAyaa50_633a5c445c646d64325c77696e646f77735c62696e5c2e2e5c2e2e5c7372635c70686f626f735c7374645c737464696f2e64Vmi2776Z12errnoEnforceFNfiLAyaZi i.obj : error LNK2019: unresolved external symbol _D3std3utf12UTFException7__ClassZ referenced in function _D3std3utf98__T13_utfExceptionVE3std8typecons55__T4FlagVAyaa19_7573655265706c6163656d656e744463686172Z4Flagi0Z13_utfExceptionFNaNfAyawZw i.obj : error LNK2019: unresolved external symbol _d_newclass referenced in function _D3std9exception135__T12errnoEnforceTiVAyaa50_633a5c445c646d64325c77696e646f77735c62696e5c2e2e5c2e2e5c7372635c70686f626f735c7374645c737464696f2e64Vmi2776Z12errnoEnforceFNfiLAyaZi i.obj : error LNK2019: unresolved external symbol _D3std9exception14ErrnoException7__ClassZ referenced in function _D3std9exception135__T12errnoEnforceTiVAyaa50_633a5c445c646d64325c77696e646f77735c62696e5c2e2e5c2e2e5c7372635c70686f626f735c7374645c737464696f2e64Vmi2776Z12errnoEnforceFNfiLAyaZi i.obj : error LNK2019: unresolved external symbol _fputc_nolock referenced in function _D3std5stdio4File17LockingTextWriter10__T3putTwZ3putMFNfwZ12trustedFPUTCFNbNiNeiPS4core4stdc5stdio6_iobufZi i.obj : error LNK2019: unresolved external symbol fwrite referenced in function _D3std5stdio21__T13trustedFwriteTaZ13trustedFwriteFNbNiNePOS4core4stdc5stdio6_iobufxAaZm i.obj : error LNK2019: unresolved external symbol _D3std5stdio4File6__dtorMFNfZv referenced in function _D3std5stdio16__T7writelnTAyaZ7writelnFNfAyaZv i.obj : error LNK2019: unresolved external symbol _d_assertp referenced in function _D3std5stdio4File17LockingTextWriter10__T3putTwZ3putMFNfwZv i.obj : error LNK2019: unresolved external symbol _D3std5stdio4File17LockingTextWriter7handle_MFNdNeZPS4core4stdc5stdio6_iobuf referenced in function _D3std5stdio4File17LockingTextWriter10__T3putTwZ3putMFNfwZv i.obj : error LNK2019: unresolved external symbol _d_arrayboundsp referenced in function _D3std5stdio4File17LockingTextWriter10__T3putTwZ3putMFNfwZv LINK : error LNK2001: unresolved external symbol _DllMainCRTStartup i.dll : fatal error LNK1120: 20 unresolved externals Error: linker exited with status 1120 |
November 01, 2017 Re: Link errors when compiling shared lib on windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Fitzpatrick | On Wednesday, 1 November 2017 at 16:02:37 UTC, Daniel Fitzpatrick wrote: > Oops, missed that! What i've tried is > > -shared -m64 i.d > -shared -m64 -defaultlib=libphobos2.dll i.d > > Still seeing a lot of linker errors. Errors for the former: Are you using LDC? That's the only way I've been able to create a working DLL. I've never had to add the -defaultlib option with LDC on Windows. Here's a post describing all the steps I took to make a DLL that can be called from R: https://lancebachmeier.com/computing/d-from-r-windows.html The references to R are not important. Should be straightforward to adopt for your use case. |
November 01, 2017 Re: Link errors when compiling shared lib on windows | ||||
---|---|---|---|---|
| ||||
Posted in reply to Daniel Fitzpatrick | On Wednesday, 1 November 2017 at 16:02:37 UTC, Daniel Fitzpatrick wrote:
> On Wednesday, 1 November 2017 at 15:52:17 UTC, kinke wrote:
>> On Wednesday, 1 November 2017 at 15:15:27 UTC, Daniel Fitzpatrick wrote:
>>> I am following this short tutorial on compiling a shared lib:
>>>
>>> https://wiki.dlang.org/Call_D_from_Ruby_using_FFI
>>>
>>> Because it's on Windows I am using these compiler options:
>>>
>>> -shared -m64 -defaultlib=libphobos2.so i.d
>>>
>>>
>>> However, I am receiving rather a lot of linker errors. Not sure what else to provide the compiler.
>>
>> Try less, especially no `-defaultlib` overridden with a Linux shared-object. You'll have to edit the hardcoded `./i.so` in the example as well obviously.
>
> Oops, missed that! What i've tried is
>
> -shared -m64 i.d
> -shared -m64 -defaultlib=libphobos2.dll i.d
>
> Still seeing a lot of linker errors. Errors for the former:
There's no shared library of Phobos for Windows with either DMD or LDC. You have to statically link to it.
|
Copyright © 1999-2021 by the D Language Foundation