How to call a function from a dll created with d ?

Vinod KC kcvinu82 at gmail.com
Sat Jul 2 20:43:41 UTC 2022


On Saturday, 2 July 2022 at 14:32:11 UTC, apz28 wrote:
>
> dmd -of=dimedll.dll dimedll.d dimedll.def
> dmd dime.d dimedll.di

Thanks for the reply. Well, I am sorry to say that your 
suggestions resulted in failure.
First of all, when I used this command -- ` dmd -of=dimedll.dll 
dimedll.d dimedll.def` I got this error message-
`Error: unrecognized file extension dll`.
So I avoided the `-of=dimedll.dll` part.
Then I compiled it with this command - `dmd -H dimedll.d 
dimedll.def`
And I got some warnings. Here are they.
```d
dimedll.def(2) : warning LNK4017: EXETYPE statement not supported 
for the target platform; ignored
dimedll.def(3) : warning LNK4017: SUBSYSTEM statement not 
supported for the target platform; ignored
dimedll.def(4) : warning LNK4017: CODE statement not supported 
for the target platform; ignored
dimedll.def(4) : warning LNK4017: DATA statement not supported 
for the target platform; ignored
    Creating library dimedll.lib and object dimedll.exp
```
I know all of them are from my `def` file. Anyways, I stepped 
forward and tried to run the main file with this dll & lib.
So I ran this command. - `dmd dime.d dimedll.di`. But I got this 
error message.
```d
dime.obj : error LNK2001: unresolved external symbol 
__D7dimedll12__ModuleInfoZ
dime.exe : fatal error LNK1120: 1 unresolved externals
Error: linker exited with status 1120
```



More information about the Digitalmars-d-learn mailing list