Thread overview
ldc-mingw - Windows sample - undefined reference to `_Dmain'
Oct 14, 2013
dnewbie
Oct 15, 2013
David Nadlinger
Oct 15, 2013
David Nadlinger
October 14, 2013
Error 'undefined reference to `_Dmain'' when compiling samples\d\winsamp.d.

Workaround:
a) add main() that calls myWinMain
b) run objcopy for setting subsystem=windows and to get rid of the 'DOS window':
objcopy --subsystem windows:5.00 winsamp.exe winsamp2.exe

Example:
http://dpaste.dzfl.pl/8698696f
October 15, 2013
On 14 Oct 2013, at 15:32, dnewbie wrote:
> Error 'undefined reference to `_Dmain'' when compiling samples\d\winsamp.d.
>
> Workaround:
> a) add main() that calls myWinMain
> b) run objcopy for setting subsystem=windows and to get rid of the 'DOS window':
> objcopy --subsystem windows:5.00 winsamp.exe winsamp2.exe
>
> Example:
> http://dpaste.dzfl.pl/8698696f

Thanks for going through the trouble to figure this one out.

We should probably handle WinMain like DMD does in the long run to make it easier for people to write bare Win32 application. But until that's done, it would be great if you could put the above information in some place where  that others can find it, e.g. the wiki.

Regarding the windows subsystem, I believe there is a flag for the MinGW linker (-mwindows? -Wl,subsystem,windows?). You could try just specifying it on the LDC command line using -L, it should save you the extra step.

David
October 15, 2013
On 15 Oct 2013, at 3:13, David Nadlinger wrote:
> -Wl,subsystem,windows

That should have been -Wl,--subsystem,windows, or for use with LDC, -L--subsystem -Lwindows.

It's been quite some while since I last messed around with those flags, and I never tried them with LDC so far.

David