How to build a static lib properly?

ryuukk_ ryuukk.dev at gmail.com
Mon Mar 6 00:55:04 UTC 2023


Hello,

I am trying to build: https://github.com/dlang-community/DCD/ as 
a static lib

In the DCD's dub i changed targetType to "staticLibrary"

Then i build:

``dub build -c library`` for the library config


But now the weird part

On my program i try to link it and i get bunch of unreloved 
symbols (druntime stuff)

Even thought i do nothing fancy on the program

I build it this way:

``dmd -m64 -g -debug dcd.lib app.d``

Nothing fancy:


```D
void main(string[] args)
{
	init_dcd();
}

extern(C) void init_dcd();
```


That init_dcd is declared this way on the dll:

```D
extern(C) export void init_dcd()
{

}
```

I get this long error full of 'unresolved external symbosl'


https://gist.github.com/ryuukk/fae57614aab40638bbe00c8d3fbba708

Anyone know what the hell is happening?


Windows10 x64
DMD32 D Compiler v2.102.1



More information about the Digitalmars-d-learn mailing list