Thread overview
How to compile with GtkD
Feb 09, 2020
mark
Feb 09, 2020
Ron Tarrant
Feb 09, 2020
mark
Re: How to compile with GtkD [solved]
Feb 09, 2020
mark
Feb 09, 2020
Mike Wey
February 09, 2020
According to the GtkD web site https://gtkd.org/ this GUI library is cross-platform, so hopefully just what I need.

The introductory blog https://gtkdcoding.com/2019/01/11/0000-introduction-to-gtkDcoding.html explains how to install and get started with GtkD on Windows (which I plan to use later on), but right now I want to start on Linux and I'm stuck.

I have LDC in $HOME/opt/ldc2-1.19.0-linux-x86_64 with the bin/ dir in my path, and GtkD 3.9.0 in $HOME/opt/GtkD3

I am trying to build a simple "hello world" app (from the gtkDcoding blog) in $HOME/app/d/gtktest (which is a dub init created directory) and have this dub.sdl:

name "gtktest"
description "Gtk Test"
authors "Mark"
targetType "executable"
dependency "gtk-d:gtkd" version=">=3.9.0"
importPaths "$HOME/opt/GtkD3"
libs "libgtkd-3"

The error I get is:

$ dub
Performing "debug" build using /home/mark/opt/bin/ldc2 for x86_64.
gtk-d:gtkd 3.9.0: target for configuration "library" is up to date.
gtktest ~master: building configuration "application"...
Linking...
/usr/bin/ld.gold: error: cannot find -llibgtkd-3
collect2: error: ld returned 1 exit status
Error: /usr/bin/cc failed with status: 1
/home/mark/opt/bin/ldc2 failed with exit code 1.

$ cd ~/opt/GtkD3
$ ls *.a
libgstreamerd-3.a
libgtkd-3.a
libgtkdsv-3.a
libpeasd-3.a
libvted-3.a

I also tried specifying libs as "gtkd-3" and had the same problem.

I can run $HOME/opt/GtkD3/TestWindow and it works fine. And I can also build it in $HOME/opt/GtkD3/demos/gtkD/TestWindow. However, it uses a dub.json with "dependencies": { "gtk-d:gtkd": {"path": "../../../" }, } and I don't know what the dub.sdl equivalent of this is. (I prefer .sdl to .json.)

February 09, 2020
On Sunday, 9 February 2020 at 11:52:19 UTC, mark wrote:

> right now I want to start on Linux and I'm stuck.
Maybe this will help...

https://gtkdcoding.com/2019/03/31/x0002-gtkd-in-a-linux-environment.html
February 09, 2020
On Sunday, 9 February 2020 at 12:03:23 UTC, Ron Tarrant wrote:
> On Sunday, 9 February 2020 at 11:52:19 UTC, mark wrote:
>
>> right now I want to start on Linux and I'm stuck.
> Maybe this will help...
>
> https://gtkdcoding.com/2019/03/31/x0002-gtkd-in-a-linux-environment.html

Unfortunately it didn't because I have locally installed LDC and GtkD.

Generally, for development I prefer to install (and on Linux build) languages and libs myself rather than using system versions.

What I really need is to know how to change my dub.sdl to send the right arguments to ldc2.
February 09, 2020
Turns out I didn't need to add lines to dub.sdl at all. So my dub.sdl is now just:

name "gtktest"
description "Gtk Test"
authors "Mark"
targetType "executable"
dependency "gtk-d:gtkd" version=">=3.9.0"

The solution was to do this:

$ dub add-path ~/opt/GtkD3/

After that it does static builds, which is great, gives me self-contained executables.
February 10, 2020
On 09-02-2020 12:52, mark wrote:
> 
> I am trying to build a simple "hello world" app (from the gtkDcoding blog) in $HOME/app/d/gtktest (which is a dub init created directory) and have this dub.sdl:
> 
> name "gtktest"
> description "Gtk Test"
> authors "Mark"
> targetType "executable"
> dependency "gtk-d:gtkd" version=">=3.9.0"
> importPaths "$HOME/opt/GtkD3"
> libs "libgtkd-3"

Libraries should be passed to dub / ld without the lib prefix, so that last line would become: libs "gtkd-3"

Since dub will build a copy of the libraries listed as dependencies, you can either remove the dependency line, or the importPaths and libs lines. Since now you are linking against both the library build by dub and the one on your system.

-- 
Mike Wey