www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.ldc - ldc-mingw - Windows sample - undefined reference to `_Dmain'

reply "dnewbie" <run3 myopera.com> writes:
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
Oct 14 2013
next sibling parent "David Nadlinger" <code klickverbot.at> writes:
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
Oct 14 2013
prev sibling parent "David Nadlinger" <code klickverbot.at> writes:
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
Oct 14 2013