Render SVG To Display And Update Periodically

Mike Parker via Digitalmars-d-learn digitalmars-d-learn at puremagic.com
Thu Oct 20 00:20:33 PDT 2016


On Thursday, 20 October 2016 at 04:52:11 UTC, Jason C. Wells 
wrote:
> This is probably a general programming question. I'll follow up 
> here since this thread is the inspiration for my current 
> question.
>
> When attempting to compile simpledisplay.d, I get the following:
>
> C:\...\dlang\arsd-master>dmd -Lgdi32.lib -L user32.lib 
> simpledisplay.d color.d

Don't pass libraries with -L. Just do it like this:

dmd gdi32.lib user32.lib


> Interestingly enough, simpledisplay.obj and simpledisplay.exe 
> are produced. Aren't errors fatal? The EXE is not a valid win32 
> application.

Those aren't errors. The linker thinks it has been passed a 
couple of options that it doesn't understand, but it will still 
proceed with the link.

>
> I am used to makefiles. The author doesn't use dub for these 
> programs. (dub ~=make?)
>
> gdi32.lib and user32.lib appear in multiple directories.  I 
> added "C:\Program Files (x86)\Windows 
> Kits\8.1\Lib\winv6.3\um\x64" to %LIB% which seemed sensible to 
> do. I still get the warning:
>
> OPTLINK : Warning 9: Unknown Option : NOIGDI32.LIBUSER32.LIB

See that OPTLINK in the error messages? That's the Digital Mars 
linker that ships with DMD. It doesn't know anything at all about 
the libraries that ship with the Windows kits. It uses the 
libraries that ship with DMD. The Windows SDK is only used when 
using the Microsoft linker, which only happens when passing -m64 
or -m32mscoff to the compiler. By default (-m32), DMD uses 
OPTLINK.

Again, just pass the libraries without -L.

>
> So, I'm still figuring out how to set up a compile. I presume 
> that dmd is not finding gdi32.lib and user32.lib.  What am I 
> missing?

Your bigger issue, and why your compilation didn't produce a 
valid executable, is that you have no main function! Try 
something like the following:

Directory tree:
- testapp
-- test1.d
--- arsd
---- simpledisplay.d
---- color.d

In test1.d, using an example copy/pasted from the simpledisplay.d 
ddoc comments:

```
import arsd.simpledisplay;
import std.conv;
void main() {
     auto window = new SimpleWindow(Size(500, 500), "My D App");
     int y = 0;
     void addLine(string text) {
         auto painter = window.draw();
         if(y + painter.fontHeight >= window.height) {
             painter.scrollArea(Point(0, 0), window.width, 
window.height, 0, painter.fontHeight);
             y -= painter.fontHeight;
         }
         painter.outlineColor = Color.red;
         painter.fillColor = Color.black;
         painter.drawRectangle(Point(0, y), window.width, 
painter.fontHeight);
         painter.outlineColor = Color.white;
         painter.drawText(Point(10, y), text);
         y += painter.fontHeight;
     }
     window.eventLoop(1000,
       () {
         addLine("Timer went off!");
       },
       (KeyEvent event) {
         addLine(to!string(event));
       },
       (MouseEvent event) {
         addLine(to!string(event));
       },
       (dchar ch) {
         addLine(to!string(ch));
       }
     );
}
```

Then run the compiler with:

dmd test1.d arsd/simpledisplay.d arsd/color.d gdi32.lib user32.lib

IIRC, you don't need to pass user32.lib, as DMD will link it in 
by default (though I may be mistaken).






More information about the Digitalmars-d-learn mailing list