March 01, 2023
https://forum.dlang.org/post/edwmddiqcsnwpliyovtc@forum.dlang.org

On Wednesday, 3 September 2014 at 09:13:52 UTC, Szymon Gatner wrote:
> On Wednesday, 3 September 2014 at 08:47:35 UTC, Rikki Cattermole wrote:
>> On 3/09/2014 7:22 p.m., Szymon Gatner wrote:
>>> [...]
>>
>> My gut feeling looking at that, is that its not linking against the c runtime.
>>
>> For reference I'm pretty sure _deh_beg is related to exception handling.
>
> Hey, for some reason I missed this:
>
> http://forum.dlang.org/thread/ji93fh$15ph$1@digitalmars.com
>
> The fix is to add main() function to D library. Don't know why it is needed for static lib but it sure helps to resolve link issues.

Strangely I just got similar link errors (phobos64.lib ... unresolved ...) building dynamic lib on Win11 (no errors on Win10, or with ldc). I found this thread and adding main() saved me.

Any expert can explain why and when main() is needed for dynamic, or static lib?
March 01, 2023
On Wednesday, 1 March 2023 at 07:15:36 UTC, Elfstone wrote:
> https://forum.dlang.org/post/edwmddiqcsnwpliyovtc@forum.dlang.org
>
> On Wednesday, 3 September 2014 at 09:13:52 UTC, Szymon Gatner wrote:
>> On Wednesday, 3 September 2014 at 08:47:35 UTC, Rikki Cattermole wrote:
>>> [...]
>>
>> Hey, for some reason I missed this:
>>
>> http://forum.dlang.org/thread/ji93fh$15ph$1@digitalmars.com
>>
>> The fix is to add main() function to D library. Don't know why it is needed for static lib but it sure helps to resolve link issues.
>
> Strangely I just got similar link errors (phobos64.lib ... unresolved ...) building dynamic lib on Win11 (no errors on Win10, or with ldc). I found this thread and adding main() saved me.
>
> Any expert can explain why and when main() is needed for dynamic, or static lib?

Oh, I'm not saved. Because now I get "only one `main` allowed" error when I link the lib.