How to call a function from a dll created with d ?
frame
frame86 at live.com
Sun Jul 3 09:43:20 UTC 2022
On Saturday, 2 July 2022 at 20:43:41 UTC, Vinod KC wrote:
> But I got this error message.
> dime.obj : error LNK2001: unresolved external symbol
> __D7dimedll12__ModuleInfoZ
> dime.exe : fatal error LNK1120: 1 unresolved externals
> Error: linker exited with status 1120
I tried the -H switch. You can't rely on that. I comment the
lines that shouldn't be there - then it should work:
dimedll.di
```d
// D import file generated from 'dimedll.d'
module dimedll;
// import core.sys.windows.dll;
// import std.stdio;
// mixin SimpleDllMain!();
export void testFunc();
```
dimedll.d:
```d
module dimedll;
import core.sys.windows.dll;
import std.stdio;
mixin SimpleDllMain;
export void testFunc() {
writeln("This is from dll");
}
```
app.d:
```d
module app;
import dimedll;
import std.stdio;
import std.stdio : log = writeln;
pragma(lib, "dimedll.lib");
void main() {
log("Lets build our own ime");
testFunc();
}
```
You should be able to change contents in the DLL and run the
executable wihtout re-compiling (the library file should be round
~2kB).
PS: ddemangle just waits for your input. You copy in the mangled
symbol like `__D7dimedll12__ModuleInfoZ` and press enter ;-)
More information about the Digitalmars-d-learn
mailing list