How to build program with DWT2 and DMD2?

JohnnyK johnnykinsey at comcast.net
Fri Aug 2 10:50:06 PDT 2013


On Friday, 2 August 2013 at 11:28:15 UTC, Jacob Carlborg wrote:
> On 2013-07-31 15:47, JohnnyK wrote:
>> Hi all,
>>   Sorry for what may seem like a simple and obvious question 
>> to most
>> DWT users.  First I would like to say that I have absolutely no
>> experience with SWT in any form.  Second I know nothing of 
>> Eclipse other
>> than that is what happens when the moon is directly between 
>> the earth
>> and the sun.  I would like to know in a few simple steps or 
>> examples how
>> to build a hello world or some other trivial GUI application 
>> with DWT.
>> Following the instructions I was able to build the Snippets 
>> but that
>> does not really tell you how to start a DWT project from 
>> scratch.  I
>> would really like to get some steps on how to start a DWT 
>> project from a
>> project folder somewhere and compile it.  So far the snippets 
>> show off
>> the abilities of the library but they are not a tutorial and 
>> don't help
>> us noobs.  The snippets would be good if they had HOW to 
>> comments or
>> other documentation that explains how to get this done.  Also 
>> it would
>> be nice if someone could share a typical directory layout of 
>> their DWT
>> programming environment and what tools(aka IDE) they use.  I 
>> am finding
>> this whole DWT thing to be a really daunting task without some 
>> kind of
>> tutoring.  I have found DWT to be really hard to get started 
>> with.  I do
>> like the fact that one can make a single executable that can 
>> be copied
>> and executed without the need to install a huge API or 
>> additional
>> baggage files before the executable will run.
>
> Hello World using DWT would look something like this:
>
> module main;
>
> import org.eclipse.swt.widgets.Display;
> import org.eclipse.swt.widgets.Shell;
>
> void main ()
> {
>     auto display = new Display;
>     auto shell = new Shell;
>     shell.open();
>
>     while (!shell.isDisposed)
>         if (!display.readAndDispatch())
>             display.sleep();
>
>     display.dispose();
> }
>
> I would recommend compiling it with rdmd (supplied with dmd) :
>
> rdmd main.d -I/path/to/dwt
>
> For learning how to use DWT I would recommend all the tutorials 
> out there for SWT. They are similar enough making it easy to 
> port for SWT (Java) code to DWT (D).

Thanks Jacob for the response but that did not work :-(  Below is 
what I get when I compile your hello world example above.


C:\Users\<myusername>\Documents\My 
Projects\Programming\DStuff\dwthelloworld>rdmd hello.d 
-IC:\GITClones\dwt
hello.d(3): Error: module Display is in file 
'org\eclipse\swt\widgets\Display.d'
  which cannot be read
import path[0] = .
import path[1] = C:\D\dmd2\windows\bin\..\..\src\phobos
import path[2] = C:\D\dmd2\windows\bin\..\..\src\druntime\import
Failed: "dmd" "-v" "-o-" "hello.d" "-I."


More information about the Digitalmars-d-dwt mailing list