Tutorial - Using the D Programming Language with Zeus

Find Tips and tricks on how to better use the Zeus IDE. Feel free to post your own tips but please do not post bug reports, feature requests or questions here.
Post Reply
Site Admin
Posts: 2496
Joined: Fri Aug 13, 2004 5:10 pm

Tutorial - Using the D Programming Language with Zeus

Post by jussij » Mon Mar 09, 2009 1:03 am

Here is a simple, step by step tutorial on how to configure Zeus to work with the D programming language compiler.

Install the DMD Compiler

1: Go to the DMD compiler download page.

2: Download the DMD D 1.0 compiler (dmd.1.030.zip) package.

3: Download the DMC Linker and Utilities (dmc.zip) package.

4: Unzip the to two packages into the c:\dmd folder location remembering to maintain the folder structure contained in the zip files.

5: Add the C:\dmd\bin\ folder to the PATH using the Windows Control Panel. More details on how to set the PATH can be found here.

NOTE: Step 5 is optional as this can also be done from within Zeus as will be shown later in this tutorial.

Create Some Code to Run Through the Compiler

1: Create the main.d file in this folder location:

Code: Select all

The code in the main.d file should look like this:

Code: Select all

import std.stdio;

// our import libraries
import mathLIB.math1;
import mathLIB.math2;

int main(char[][] args)
    real r1 = 0.95;
    writefln("real r1 = %f", r1);

    real r2 = __sqr(r1) * -1.0;
    writefln("real r2 = %f", r2);

    real r3 = __abs(r2);
    writefln("real r3 = %f", r3);

    real r4 = __acos(r1);
    writefln("real r4 = %f", r4);

    real r5 = __asin(r1);
    writefln("real r5 = %f", r5);

    real r6 = __atan(r1);
    writefln("real r6 = %f", r6);

	return 1;
2: Create the math1.d and math2.d files in these folder locations:

Code: Select all

The code in the math1.d file should look like this:

Code: Select all

module mathLIB.math1;

private import std.c.math;

real __abs(real x)
    return fabs(x);

real __sqr(real n)
    return n * n;

int __sign(real n)
    return (n > 0 ? +1 : (n < 0 ? -1 : 0));
The code in the math2.d file should look like this:

Code: Select all

module mathLIB.math2;

private import std.c.math;

real __acos(real x)
    return std.c.math.acosl(x);

real __asin(real x)
    return std.c.math.asinl(x);

real __atan(real x)
    return std.c.math.atanl(x);
Create a Zeus Workspace to Manage these Project Files

1: With Zeus running use the Workspace, New menu and in the resulting dialog fill in the following details:
  • Workspace Name: My Example
  • Workspace Directory: c:\d\
2: Hit the Workspace Builder button.

3: In the resulting dialog set the File Extensions to *.d and hit the Search button.

4: Hit the Save button and then hit the Close button.

5: Hit the Load button to load the newly created workspace into Zeus.

At this point Zeus will have create a Workspace with a project tree that matches the project tree described earlier and Zeus will have also created the class browsing and intellesensing information for these two projects.

For example, by clicking on the main.d file in the Main files section of the workspace, the file will be loaded into Zeus. Select the __atan function from the code and use the right mouse click, Tag Current Word popup menu to have Zeus load up the math2.d file at the location of the __atan function.

Configuring the Zeus Workspace to Work with the DMD Compiler

1: With the main.d file loaded and set as the active file, click on the compile toolbar button or use the Compile, Compile menu and the following error output window should be displayed:

Code: Select all

'dmd.exe' is not recognized as an internal or external command, operable program or batch file.
This error is generated because the C:\dmd\bin\ folder is not in the system PATH. To fix this, the folder location could be added to the PATH using the Windows Control Panel or alternatively the PATH can be configued into the Zeus workspace.

To configure the PATH into the workspace, use the Workspace, Options menu, select the General section and in the PATH entry field, add or append the C:\dmd\bin\; value.

IMPORTANT NOTE: Make sure the PATH is added to both projects in the workspace.

Now when the compile button is hit the following output will be produced:

Code: Select all

C:\d\main\main.d(12): Error: undefined identifier __sqr
C:\d\main\main.d(12): Error: function expected before (), not __sqr of type int
C:\d\main\main.d(14): Error: undefined identifier __abs
C:\d\main\main.d(14): Error: function expected before (), not __abs of type int
C:\d\main\main.d(16): Error: undefined identifier __acos
C:\d\main\main.d(16): Error: function expected before (), not __acos of type int
C:\d\main\main.d(18): Error: undefined identifier __asin
C:\d\main\main.d(18): Error: function expected before (), not __asin of type int
C:\d\main\main.d(20): Error: undefined identifier __atan
C:\d\main\main.d(20): Error: function expected before (), not __atan of type int
What has happened in this case is Zeus has run the following D compiler command line as defined in the D Document type.

Code: Select all

dmd.exe -c -debug -v $fn
As the error messages suggest the code in the main.d is missing some external functions, which is not surprising since these functions are defined in the math1.d and math2.d files of the other project and the files do not appear anywhere on this default command line.

One way to fix this error would be to add all the files to the command line, but a much better approach would be to use a build manager to handle the building of the project.

So it's time to configure Zeus to use a build manager.

Related Topics:
Getting the D language debugger to work with Zeus.
Intergrating the D programming language help file.
Intergrating the D programming language Tango help file.
Writing Zeus macros using D scripting module.
Using the dfmt with Zeus
Using the Dscanner (D Language) inside Zeus
Using the DCD with Zeus

Post Reply
kuchnie warszawa opinie

Who is online

Users browsing this forum: No registered users and 0 guests