Re: Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.
On 02/10/2020 9:33 PM, Imperatorn wrote: Did you create a D-partition just for D. Pro You can mount directories as a drive on Windows. https://docs.microsoft.com/en-us/windows-server/administration/windows-commands/subst
Re: Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.
On Friday, 2 October 2020 at 08:33:25 UTC, Imperatorn wrote: On Friday, 2 October 2020 at 08:07:33 UTC, Ferhat Kurtulmuş wrote: On Friday, 2 October 2020 at 07:34:03 UTC, WhatMeWorry wrote: On Thursday, 1 October 2020 at 21:56:46 UTC, Ferhat Kurtulmuş wrote: [...] Yes, I've been doing that. [...] The only msvcrt.lib I can find on my Windows 10 machine is: "C:\Windows Kits\10\Lib\10.0.19041.0\um\x64\ntstc_msvcrt.lib" Also on Microsoft's docs https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=vs-2019 it talks about a ucrt.lib? Here are the steps I used with success: in a VCx64 cmd -> set PATH=%PATH%;D:\dlang\dmd.2.094.0.windows\dmd2\windows\bin64 Did you create a D-partition just for D. Pro Haha. Yes my c compiler is also located at c:\c
Re: Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.
On Friday, 2 October 2020 at 08:07:33 UTC, Ferhat Kurtulmuş wrote: On Friday, 2 October 2020 at 07:34:03 UTC, WhatMeWorry wrote: On Thursday, 1 October 2020 at 21:56:46 UTC, Ferhat Kurtulmuş wrote: On Thursday, 1 October 2020 at 21:35:42 UTC, WhatMeWorry wrote: [...] 1) try running your commands in Visual Studio Native x64 CMD. Yes, I've been doing that. 2) try link with msvcrt.lib The only msvcrt.lib I can find on my Windows 10 machine is: "C:\Windows Kits\10\Lib\10.0.19041.0\um\x64\ntstc_msvcrt.lib" Also on Microsoft's docs https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=vs-2019 it talks about a ucrt.lib? Here are the steps I used with success: in a VCx64 cmd -> set PATH=%PATH%;D:\dlang\dmd.2.094.0.windows\dmd2\windows\bin64 Did you create a D-partition just for D. Pro
Re: Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.
On Friday, 2 October 2020 at 07:34:03 UTC, WhatMeWorry wrote: On Thursday, 1 October 2020 at 21:56:46 UTC, Ferhat Kurtulmuş wrote: On Thursday, 1 October 2020 at 21:35:42 UTC, WhatMeWorry wrote: On Thursday, 1 October 2020 at 20:28:58 UTC, kinke wrote: [...] Thanks all. I've gotten it to work with: [...] [...] [...] total = 12 [...] 1) try running your commands in Visual Studio Native x64 CMD. Yes, I've been doing that. 2) try link with msvcrt.lib The only msvcrt.lib I can find on my Windows 10 machine is: "C:\Windows Kits\10\Lib\10.0.19041.0\um\x64\ntstc_msvcrt.lib" Also on Microsoft's docs https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=vs-2019 it talks about a ucrt.lib? Here are the steps I used with success: in a VCx64 cmd -> set PATH=%PATH%;D:\dlang\dmd.2.094.0.windows\dmd2\windows\bin64 module user; import std.stdio; import mydll; // Yes, I imported the dll here //export { int myAddSeven(int a, int b); } void main() { int total = mydll.myAddSeven(2, 3); writeln(total); } - module mydll; export extern(D) { int myAddSeven(int a, int b) { return a+b+7; } /* <-- function body */ } --- dmd -m64 -ofmydll.dll mydll.d -L/NOENTRY -L/DLL dmd -m64 user.d mydll.lib
Re: Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.
On Thursday, 1 October 2020 at 21:56:46 UTC, Ferhat Kurtulmuş wrote: On Thursday, 1 October 2020 at 21:35:42 UTC, WhatMeWorry wrote: On Thursday, 1 October 2020 at 20:28:58 UTC, kinke wrote: [...] Thanks all. I've gotten it to work with: [...] [...] [...] total = 12 [...] 1) try running your commands in Visual Studio Native x64 CMD. Yes, I've been doing that. 2) try link with msvcrt.lib The only msvcrt.lib I can find on my Windows 10 machine is: "C:\Windows Kits\10\Lib\10.0.19041.0\um\x64\ntstc_msvcrt.lib" Also on Microsoft's docs https://docs.microsoft.com/en-us/cpp/c-runtime-library/crt-library-features?view=vs-2019 it talks about a ucrt.lib?
Re: Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.
On Thursday, 1 October 2020 at 21:35:42 UTC, WhatMeWorry wrote: On Thursday, 1 October 2020 at 20:28:58 UTC, kinke wrote: [...] Thanks all. I've gotten it to work with: [...] [...] [...] total = 12 [...] 1) try running your commands in Visual Studio Native x64 CMD. 2) try link with msvcrt.lib
Re: Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.
On Thursday, 1 October 2020 at 20:28:58 UTC, kinke wrote: On Thursday, 1 October 2020 at 20:03:19 UTC, WhatMeWorry wrote: Yes, but shouldn't the /NOENTRY option take care of that. Say, I just want to make a DLL of simple functions. Your little example has 2 problems, the first being an incompatible extern(D) ex/import (mydll.myAddSeven vs. user.myAddSeven) and the second being an incomplete/wrong linker cmdline. When changing the myAddSeven declarations to extern(C++) (another option being a mydll.di header for the import), it works with dmd -m64 -shared -L/NOENTRY mydll.d dmd -m64 user.d mydll.lib For more details, see also https://wiki.dlang.org/Win32_DLLs_in_D. Thanks all. I've gotten it to work with: dmd -m64 -ofmydll.dll mydll.d -L/NOENTRY -L/DLL dmd -m64 user.d mydll.lib user.exe total = 12 But then I got cocky and decided to just added a writeln() in the mydll.d file and I've been fighting this link error ever since: C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\bin\Hostx64\x64\link.exe /NOLOGO "mydll.obj" /OUT:"mydll.dll" /DEFAULTLIB:phobos64 /NOENTRY /DLL /OPT:NOICF /LIBPATH:"C:\Program Files (x86)\Microsoft Visual Studio\2019\Community\VC\Tools\MSVC\14.27.29110\lib\x64" legacy_stdio_definitions.lib /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\Lib\10.0.18362.0\ucrt\x64" /LIBPATH:"C:\Program Files (x86)\Windows Kits\10\lib\10.0.18362.0\um\x64" Creating library mydll.lib and object mydll.exp mydll.obj : error LNK2019: unresolved external symbol fwrite referenced in function _D3std5stdio__T13trustedFwriteTaZQsFNbNiNePOS4core4stdcQBx6_iobufxAaZm phobos64.lib(object_72_81a.obj) : error LNK2001: unresolved external symbol memcpy phobos64.lib(exception_cf4_fff.obj) : error LNK2001: unresolved external symbol memcpy phobos64.lib(bits_23fa_21c.obj) : error LNK2001: unresolved external symbol memcpy phobos64.lib(gc_2413_a4e.obj) : error LNK2001: unresolved external symbol memcpy phobos64.lib(gc_2415_a03.obj) : error LNK2001: unresolved external symbol memcpy phobos64.lib(gc_2478_432.obj) : error LNK2001: unresolved external symbol memcpy o o o
Re: Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.
On Thursday, 1 October 2020 at 20:03:19 UTC, WhatMeWorry wrote: Yes, but shouldn't the /NOENTRY option take care of that. Say, I just want to make a DLL of simple functions. Your little example has 2 problems, the first being an incompatible extern(D) ex/import (mydll.myAddSeven vs. user.myAddSeven) and the second being an incomplete/wrong linker cmdline. When changing the myAddSeven declarations to extern(C++) (another option being a mydll.di header for the import), it works with dmd -m64 -shared -L/NOENTRY mydll.d dmd -m64 user.d mydll.lib For more details, see also https://wiki.dlang.org/Win32_DLLs_in_D.
Re: Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.
On Thursday, 1 October 2020 at 09:22:29 UTC, user1234 wrote: On Wednesday, 30 September 2020 at 11:45:53 UTC, Ferhat Kurtulmuş wrote: On Tuesday, 29 September 2020 at 21:22:21 UTC, WhatMeWorry wrote: module user; export { int myAddSeven(int a, int b); } [...] it is better to use this template https://github.com/dlang/dmd/tree/master/samples/mydll You don't have a DllMain. yeah that's the problem, check [0] OP. The author makes commercial dll on windows so he knows what he speaks about [0] https://forum.dlang.org/post/mscgsclxwtjcferfx...@forum.dlang.org Yes, but shouldn't the /NOENTRY option take care of that. Say, I just want to make a DLL of simple functions.
Re: Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.
On Tuesday, 29 September 2020 at 21:22:21 UTC, WhatMeWorry wrote: module user; export { int myAddSeven(int a, int b); } [...] As example, DLL: https://github.com/vitalfadeev/dlang-dll
Re: Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.
On Wednesday, 30 September 2020 at 11:45:53 UTC, Ferhat Kurtulmuş wrote: On Tuesday, 29 September 2020 at 21:22:21 UTC, WhatMeWorry wrote: module user; export { int myAddSeven(int a, int b); } [...] it is better to use this template https://github.com/dlang/dmd/tree/master/samples/mydll You don't have a DllMain. yeah that's the problem, check [0] OP. The author makes commercial dll on windows so he knows what he speaks about [0] https://forum.dlang.org/post/mscgsclxwtjcferfx...@forum.dlang.org
Re: Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.
On Tuesday, 29 September 2020 at 21:22:21 UTC, WhatMeWorry wrote: module user; export { int myAddSeven(int a, int b); } [...] it is better to use this template https://github.com/dlang/dmd/tree/master/samples/mydll You don't have a DllMain.
Trying to create a trivial 64 bit D Lang DLL on a Windows 10 machine and cant get past linking.
module user; export { int myAddSeven(int a, int b); } void main() { int total = myAddSeven(2, 3); } dmd -m64 -c user.d module mydll; export extern(D) { int myAddSeven(int a, int b) { return a+b+7; } /* <-- function body */ } dmd -c -shared -m64 mydll.d link mydll.obj /DLL /NOENTRY Microsoft (R) Incremental Linker Version 14.27.29111.0 Copyright (C) Microsoft Corporation. All rights reserved. Creating library mydll.lib and object mydll.exp link user.obj /implib:mydll.lib Microsoft (R) Incremental Linker Version 14.27.29111.0 Copyright (C) Microsoft Corporation. All rights reserved. LINK : fatal error LNK1104: cannot open file 'phobos64.lib' or when I give the linker phobos64.lib link user.obj /implib:mydll.lib /LIBPATH:C:\D\dmd2\windows\lib64 Microsoft (R) Incremental Linker Version 14.27.29111.0 Copyright (C) Microsoft Corporation. All rights reserved. user.obj : error LNK2019: unresolved external symbol __imp__D4user10myAddSevenFiiZi referenced in function _Dmain phobos64.lib(stacktrace_1be8_3e5.obj) : error LNK2019: unresolved external symbol snprintf referenced in function _D4core3sys7windows10stacktrace10StackTrace13resolveNoSyncFAxmZAAa phobos64.lib(demangle_c96_79b.obj) : error LNK2001: unresolved external symbol snprintf phobos64.lib(parseoptions_e2c_21b.obj) : error LNK2001: unresolved external symbol snprintf phobos64.lib(parseoptions_e2c_21b.obj) : error LNK2019: unresolved external symbol sscanf referenced in function _D4core8internal12parseoptions5parseFNbNiAxaKANgaKfQkZb user.exe : fatal error LNK1120: 3 unresolved externals