Search
How to build program with DWT2 and DMD2?
Jul 31, 2013
JohnnyK
Aug 02, 2013
Jacob Carlborg
Aug 02, 2013
JohnnyK
Aug 06, 2013
Jacob Carlborg
Aug 06, 2013
JohnnyK
Aug 07, 2013
Jacob Carlborg
Aug 07, 2013
Jacob Carlborg
Aug 07, 2013
JohnnyK
Aug 07, 2013
Jacob Carlborg
Aug 07, 2013
JohnnyK
Aug 07, 2013
Druzhinin Alexandr
Aug 08, 2013
JohnnyK
Aug 08, 2013
JohnnyK
Aug 08, 2013
Jacob Carlborg
Aug 08, 2013
JohnnyK
Aug 19, 2013
Kagamin
Aug 20, 2013
JohnnyK
Aug 20, 2013
Jacob Carlborg
Aug 21, 2013
JohnnyK
Aug 21, 2013
Jacob Carlborg
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.


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)
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).

--
/Jacob Carlborg

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)
>             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.

hello.d(3): Error: module Display is in file 'org\eclipse\swt\widgets\Display.d'
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."

On 2013-08-02 19:50, JohnnyK wrote:

> Thanks Jacob for the response but that did not work :-(  Below is what I
> get when I compile your hello world example above.
>
>
> 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'
> 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."

If you have cloned the git repository into C:\GITClones\dwt you should compile it like this:

rdmd hello.d -IC:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src -IC:\GITClones\dwt\base\src

Also make sure you cloned the repository using "git clone --recursive". This will clone the submodules as well.

--
/Jacob Carlborg

On Tuesday, 6 August 2013 at 11:32:44 UTC, Jacob Carlborg wrote:
> On 2013-08-02 19:50, JohnnyK wrote:
>
> If you have cloned the git repository into C:\GITClones\dwt you should compile it like this:
>
> rdmd hello.d -IC:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src -IC:\GITClones\dwt\base\src
>
> Also make sure you cloned the repository using "git clone --recursive". This will clone the submodules as well.

yeah that did not work for me either.  As you can see below it is the same as before.

llo.d -IC:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src -IC:\GITClones\dwt\
base\src
hello.d(3): Error: module Display is in file 'org\eclipse\swt\widgets\Display.d'
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."

The Display.d is at C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src\org\eclipse\swt\widgets on my windows box.

All I know is that the snippets do compile so I am very confused as to why this will not.  GIT does not work directly here at work.  The company I work for uses a proxy server so I had to put it through a NTLMaps program to handle the companies proxy authentication.  So when I tried to use recursive that did not work because to make it work I had to use HTTP: instead of GIT: on the url but the sub-modules tried to use GIT: as the protocol in the URL.  I then cloned the sub-modules individually so that I could get the snippets to compile which I did and most of them compiled.  The only ones that did not compile are those looking for the Browser.d file and that use some lib called derelict whatever that is.
Honestly I see GIT to be a big stumbling block for those of us that just want to use your wares.  If I was contributing then sure I can see where GIT would help but all I want to do is download a and use the library for now.  Anyway I appreciate your help but I may need to use some other widget toolkit if I can find one.  However right now the only real toolkit that comes close to my requirements is DWT but if I cannot get it to compile code outside it's development folders I don't think it will be of much practical use to me.

My Widget Tool Kit Needs:
Executable File size no larger than 5MB (minus resource/baggage files) would like less than 1MB if possible.
Must compile and run everywhere DMD does (mainly Windows & Linux).
Is self contained in a file or 2 and does not need a separate install package.
Can be copied to a directory and run with out modifying OS configurations or touching other files that are not part of the application.
Must look like or be native interface.
Must have a DateTime, Treeview, and Table/Grid widgets.  These don't need data binding but that would be nice.
Would like to have drag-n-drop plus clipboard support as appropriate for the OS.

As you can see above most of these needs can be accomplished by DWT which is evident by the snippets but I just need to be able to compile from everywhere.  Maybe it is my configuration here.  If I get a chance when I get home tonight I will try to compile this on my Linux box and let you know.  I have a virtual XP machine I can try as well.  I will let you know and again thanks for your help and patients.

On 2013-08-06 16:49, JohnnyK wrote:

> yeah that did not work for me either.  As you can see below it is the
> same as before.
>
> The Display.d is at
> C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src\org\eclipse\swt\widgets
> on my windows box.

Oh, I know what the problem is now. You need to pass the -I flags before the hello.d file.

RDMD works like this: all flags passed before the D file will be passed to the compiler. All flags passed after the D file will be passed to the compiled application when it's run.

> All I know is that the snippets do compile so I am very confused as to
> why this will not.  GIT does not work directly here at work.  The
> company I work for uses a proxy server so I had to put it through a
> NTLMaps program to handle the companies proxy authentication.  So when I
> tried to use recursive that did not work because to make it work I had
> to use HTTP: instead of GIT: on the url but the sub-modules tried to use
> GIT: as the protocol in the URL.  I then cloned the sub-modules
> individually so that I could get the snippets to compile which I did and
> most of them compiled.  The only ones that did not compile are those
> looking for the Browser.d file and that use some lib called derelict
> whatever that is.
> Honestly I see GIT to be a big stumbling block for those of us that just
> want to use your wares.  If I was contributing then sure I can see where
> GIT would help but all I want to do is download a and use the library
> for now.  Anyway I appreciate your help but I may need to use some other
> widget toolkit if I can find one.  However right now the only real
> toolkit that comes close to my requirements is DWT but if I cannot get
> it to compile code outside it's development folders I don't think it
> will be of much practical use to me.

I have no idea if that will include the submodules or not.

Ideally we will one day have a package manager for D making this much easier.

--
/Jacob Carlborg

On 2013-08-07 11:48, Jacob Carlborg wrote:

> RDMD works like this: all flags passed before the D file will be passed
> to the compiler. All flags passed after the D file will be passed to the
> compiled application when it's run.

You can also pass --build-only if you don't want to run the resulting binary.

--
/Jacob Carlborg

On Wednesday, 7 August 2013 at 09:49:50 UTC, Jacob Carlborg wrote:
> On 2013-08-07 11:48, Jacob Carlborg wrote:
>
>> RDMD works like this: all flags passed before the D file will be passed
>> to the compiler. All flags passed after the D file will be passed to the
>> compiled application when it's run.
>
> You can also pass --build-only if you don't want to run the resulting binary.

Well now I get these errors

C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src -IC:\GITClones\dwt\base\src
hello.d
C:\GITClones\dwt\base\src\java\lang\util.d(595): Error: need -Jpath switch to im
port text file org.eclipse.swt.internal.SWTMessages.properties
C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src\org\eclipse\swt\internal\Co
mpatibility.d(332): Error: template instance java.lang.util.getImportData!("org.
eclipse.swt.internal.SWTMessages.properties") error instantiating
C:\GITClones\dwt\base\src\java\lang\util.d(595): Error: need -Jpath switch to im
port text file org.eclipse.swt.internal.SWTMessages_ar.properties
C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src\org\eclipse\swt\internal\Co
mpatibility.d(332): Error: template instance java.lang.util.getImportData!("org.
eclipse.swt.internal.SWTMessages_ar.properties") error instantiating
C:\GITClones\dwt\base\src\java\lang\util.d(595): Error: need -Jpath switch to im
port text file org.eclipse.swt.internal.SWTMessages_cs.properties
C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src\org\eclipse\swt\internal\Co
mpatibility.d(332): Error: template instance java.lang.util.getImportData!("org.
eclipse.swt.internal.SWTMessages_cs.properties") error instantiating
C:\GITClones\dwt\base\src\java\lang\util.d(595): Error: need -Jpath switch to im
port text file org.eclipse.swt.internal.SWTMessages_da.properties
C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src\org\eclipse\swt\internal\Co
mpatibility.d(332): Error: template instance java.lang.util.getImportData!("org.
eclipse.swt.internal.SWTMessages_da.properties") error instantiating
C:\GITClones\dwt\base\src\java\lang\util.d(595): Error: need -Jpath switch to im
port text file org.eclipse.swt.internal.SWTMessages_de.properties
C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src\org\eclipse\swt\internal\Co
mpatibility.d(332): Error: template instance java.lang.util.getImportData!("org.
eclipse.swt.internal.SWTMessages_de.properties") error instantiating
C:\GITClones\dwt\base\src\java\lang\util.d(595): Error: need -Jpath switch to im
port text file org.eclipse.swt.internal.SWTMessages_el.properties
C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src\org\eclipse\swt\internal\Co
mpatibility.d(332): Error: template instance java.lang.util.getImportData!("org.
eclipse.swt.internal.SWTMessages_el.properties") error instantiating
C:\GITClones\dwt\base\src\java\lang\util.d(595): Error: need -Jpath switch to im
port text file org.eclipse.swt.internal.SWTMessages_es.properties
C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src\org\eclipse\swt\internal\Co
mpatibility.d(332): Error: template instance java.lang.util.getImportData!("org.
eclipse.swt.internal.SWTMessages_es.properties") error instantiating
C:\GITClones\dwt\base\src\java\lang\util.d(595): Error: need -Jpath switch to im
port text file org.eclipse.swt.internal.SWTMessages_fi.properties
C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src\org\eclipse\swt\internal\Co
mpatibility.d(332): Error: template instance java.lang.util.getImportData!("org.
eclipse.swt.internal.SWTMessages_fi.properties") error instantiating
C:\GITClones\dwt\base\src\java\lang\util.d(595): Error: need -Jpath switch to im
port text file org.eclipse.swt.internal.SWTMessages_fr.properties
C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src\org\eclipse\swt\internal\Co
mpatibility.d(332): Error: template instance java.lang.util.getImportData!("org.
eclipse.swt.internal.SWTMessages_fr.properties") error instantiating
C:\GITClones\dwt\base\src\java\lang\util.d(595): Error: need -Jpath switch to im
port text file org.eclipse.swt.internal.SWTMessages_hu.properties
C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src\org\eclipse\swt\internal\Co
mpatibility.d(332): Error: template instance java.lang.util.getImportData!("org.
eclipse.swt.internal.SWTMessages_hu.properties") error instantiating
C:\GITClones\dwt\base\src\java\lang\util.d(595): Error: need -Jpath switch to im
port text file org.eclipse.swt.internal.SWTMessages_it.properties
Failed: "dmd" "-IC:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src" "-IC:\GIT
Clones\dwt\base\src" "-v" "-o-" "hello.d" "-I."

BTW I got git to work with NTLMaps also there is a separate zip file for each module no issue.  Sorry I did not get a chance to try this on my Linux box yesterday.  BTW I did copy the hello.d file over to the snippets folder and used the same command line that compiles regular snippets to compile this and it worked just fine.  So basically I put hello.d in the C:\GITClones\dwt\org.eclipse.swt.snippets\src\org\eclipse\swt\snippets and used the following command to compile it rdmd build swtsnippets[hello] from the C:\GITClones\dwt directory.  This built a executable called Swthello.exe in C:\GITClones\dwt\bin directory.  So I know the code compiles and runs without issue.  I just don't know the magic that build.d is performing so that I can replicate it outside the dwt directory structures.  I read through build.d and it seems kind of over complicating but I guess the complexity is obviously needed because I can't seem to get it to compile any other way.  The rsp file that build.d uses has 30 lines that it sends to dmd.  Poor dmd... ;)  Oh well maybe will just need more time working with dmd and it's toolset before I take on something this big.  Rome wasn't built in a day but then again the Romans did not have D with build.d either.


On 2013-08-07 16:04, JohnnyK wrote:

> Well now I get these errors
>
> Projects\Programming\DStuff\dwthelloworld>rdmd -I
> C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src
> -IC:\GITClones\dwt\base\src
>   hello.d
> C:\GITClones\dwt\base\src\java\lang\util.d(595): Error: need -Jpath
> switch to im
> port text file org.eclipse.swt.internal.SWTMessages.properties
> C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src\org\eclipse\swt\internal\Co

-JC:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\res

To the result of the flags (before hello.d).

--
/Jacob Carlborg

On Wednesday, 7 August 2013 at 15:42:32 UTC, Jacob Carlborg wrote:
> On 2013-08-07 16:04, JohnnyK wrote:
>
>> Well now I get these errors
>>
>> Projects\Programming\DStuff\dwthelloworld>rdmd -I
>> C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src
>> -IC:\GITClones\dwt\base\src
>>  hello.d
>> C:\GITClones\dwt\base\src\java\lang\util.d(595): Error: need -Jpath
>> switch to im
>> port text file org.eclipse.swt.internal.SWTMessages.properties
>> C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src\org\eclipse\swt\internal\Co
>
>
> -JC:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\res
>
> To the result of the flags (before hello.d).

Still no love for me from DWT :(

C:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\src -IC:\GITClones\dwt\base\src
-JC:\GITClones\dwt\org.eclipse.swt.win32.win32.x86\res hello.d
OPTLINK (R) for Win32  Release 8.00.12
olepro32.lib
oleacc.lib
usp10.lib
msimg32.lib
opengl32.lib
shlwapi.lib
dwt-base.lib
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _CreateStdAccessibleObject@16
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _LresultFromObject@12
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _TransparentBlt@44
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _AlphaBlend@44
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptFreeCache@4
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptCPtoX@36
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptTextOut@56
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptJustify@24
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptLayout@16
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptGetLogicalWidths@28
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptBreak@16
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptShape@40
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptGetFontProperties@12
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptGetCMap@24
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptPlace@36
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptStringFree@4
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptStringOut@32
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptStringAnalyse@52
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptApplyDigitSubstitution@12
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptRecordDigitSubstitution@8
E0E32294\objs\hello.obj(hello)
Error 42: Symbol Undefined _ScriptItemize@28