Win32 example/tutorial with GC?

David Friedman dvdfrdmn at users.ess-eff.net
Tue May 1 04:09:59 PDT 2007


Johnny wrote:
> Hello
> 
> I'm trying to make a simple windows GUI application using D.
> First, I used DMD, and I suffered a lot due to it's OMF format. So I decided
> to switch to GDC (with MinGW). But I still receive linking errors related to
> Phobos :-(
> 
> Are there any examples or tutorials that can help in this area? I.e. ones
> that show how to set the GC correctly... There are such examples for DMD,
> but I couldn't find similar examples for GDC... So any help?
> 
> Thanks
> john
> 
> 
> 

If you are linking with other libraries, you may need to explicitly link 
against -lgphobos with that library early on the command line:

gdc a.o b.o -lgphobos -lwsock32

If you do not need a custom WinMain, just write the normal D main(). 
Otherwise, the easiest thing to do is call _d_run_Dmain:

---
import std.c.windows.windows;
extern (C) int _d_run_Dmain(int argc, char **argv);
extern (Windows)
int WinMain(HINSTANCE hInstance,
         HINSTANCE hPrevInstance,
         LPSTR lpCmdLine,
         int nCmdShow)
{
     char * fake_argv ="x";
     return _d_run_Dmain(1, & fake_argv);
}

int main(char[][] args) {
   return 0;
}
---

David


More information about the D.gnu mailing list