www.digitalmars.com         C & C++   DMDScript  

digitalmars.D - "mydll" sample from C:\D\dmd2\samples\d\mydll\ doesn't compile. DMD

reply Vitalii <yvitaliy glonass-iac.ru> writes:
Hi everyone!

I need sample to make 64-bit dll in D with C interface.
I tried to use "mydll" sample in C:\D\dmd2\samples\d\mydll\, but 
it fails:
----------
C:\D\dmd2\samples\d\mydll>..\..\..\windows\bin\dmd -m64 
-ofmydll.dll -L/IMPLIB mydll.d dll.d mydll.def
LINK : fatal error LNK1146: no argument for "/IMPLIB" parameter
Error: linker exited with status 1146

C:\D\dmd2\samples\d\mydll>..\..\..\windows\bin\dmd -m64 test.d 
mydll.lib
LINK : fatal error LNK1104: не удается открыть файл
"mydll.lib"
Error: linker exited with status 1104
----------

32-bit version (which is usless for me) gives another error 
messages:
----------
C:\D\dmd2\samples\d\mydll>build.bat
C:\D\dmd2\samples\d\mydll>..\..\..\windows\bin\dmd -ofmydll.dll 
-L/IMPLIB mydll.d dll.d mydll.def
C:\D\dmd2\samples\d\mydll>..\..\..\windows\bin\dmd test.d 
mydll.lib
OPTLINK (R) for Win32  Release 8.00.17
Copyright (C) Digital Mars 1989-2013  All rights reserved.
http://www.digitalmars.com/ctg/optlink.html
test.obj(test)
  Error 42: Symbol Undefined _D5mydll8dllprintFZv
Error: linker exited with status 1
----------

In earlier version 2.073.3 of DMD compiler 32-bit version of 
"mydll" builds successfully, but 64-bit get the same error 
messages as above. I use 64-bit path settings. DMD compiler 
version 2.079.0, Windows 7 Pro (6.1, build 7601: Service Pack 1).
Mar 21 2018
parent reply Mike Parker <aldacron gmail.com> writes:
On Wednesday, 21 March 2018 at 08:30:54 UTC, Vitalii wrote:

 In earlier version 2.073.3 of DMD compiler 32-bit version of 
 "mydll" builds successfully, but 64-bit get the same error 
 messages as above. I use 64-bit path settings. DMD compiler 
 version 2.079.0, Windows 7 Pro (6.1, build 7601: Service Pack 
 1).
-m64 uses the MS linker, not Optlink. You don't need /IMPLIB for that unless you intend to change the default name for the generated import library. This should build a 64-bit DLL for you: dmd -m64 -ofmydll.dll -L/DLL mydll.d dll.d
Mar 21 2018
parent reply Mike Parker <aldacron gmail.com> writes:
On Wednesday, 21 March 2018 at 08:44:15 UTC, Mike Parker wrote:
 On Wednesday, 21 March 2018 at 08:30:54 UTC, Vitalii wrote:

 In earlier version 2.073.3 of DMD compiler 32-bit version of 
 "mydll" builds successfully, but 64-bit get the same error 
 messages as above. I use 64-bit path settings. DMD compiler 
 version 2.079.0, Windows 7 Pro (6.1, build 7601: Service Pack 
 1).
-m64 uses the MS linker, not Optlink. You don't need /IMPLIB for that unless you intend to change the default name for the generated import library. This should build a 64-bit DLL for you: dmd -m64 -ofmydll.dll -L/DLL mydll.d dll.d
And actually, the -of parameter is superfluous in this case. The DLL will pick get the name of the first source module by default.
Mar 21 2018
parent Vitalii <yvitaliy glonass-iac.ru> writes:
On Wednesday, 21 March 2018 at 08:46:12 UTC, Mike Parker wrote:
 On Wednesday, 21 March 2018 at 08:44:15 UTC, Mike Parker wrote:
 On Wednesday, 21 March 2018 at 08:30:54 UTC, Vitalii wrote:

 In earlier version 2.073.3 of DMD compiler 32-bit version of 
 "mydll" builds successfully, but 64-bit get the same error 
 messages as above. I use 64-bit path settings. DMD compiler 
 version 2.079.0, Windows 7 Pro (6.1, build 7601: Service Pack 
 1).
-m64 uses the MS linker, not Optlink. You don't need /IMPLIB for that unless you intend to change the default name for the generated import library. This should build a 64-bit DLL for you: dmd -m64 -ofmydll.dll -L/DLL mydll.d dll.d
And actually, the -of parameter is superfluous in this case. The DLL will pick get the name of the first source module by default.
Thank you very much! Now it compiles successfully.
Mar 21 2018