Linux & DMD & GtkD

Russel Winder russel at winder.org.uk
Mon Feb 18 06:29:54 UTC 2019


On Sat, 2019-02-16 at 16:28 +0000, Ron Tarrant via Digitalmars-d-learn wrote:
> 
> […]

Apologies for the delay in replying.

> It's been almost 20 years since I used Linux and my notes are 
> long gone. A ton of things have changed. Like, for instance, it 
> found all my hardware this time, without me getting involved. But 
> also the software installation managers and lots of other things 
> are completely unrecognizable. On top of that, my brain has 
> (unfortunately) been molded into the Windows/Microsoft way of 
> thinking.

Personally I use aptitude for all Debian package management – Ubuntu and Mint
are the same as Debian really in this but with different package repositories.
Some people use apt and some apt-get, etc. For me the advantage of aptitude is
that it has a curses-based GUI as well as command line.

> I guess what I'm hoping for is a step-by-step, 
> full-on-hand-holding, large-print with pictures tutorial for how 
> to get GtkD and (I guess) dub working. I know the stuff you wrote 
> is probably helpful, but I'm not well-enough versed in Linux or 
> any flavour of UNIX ATM to understand it, pick which option I 
> should use, and to put these commands in proper order.

|> aptitude search gtkd
i A libgtkd-3-0                        - GTK+ graphical user interface library
- D bin
i A libgtkd-3-dev                      - GTK+ graphical user interface library
- devel
p   libgtkd3-67                        - gtkd3 for dmd2 (runtime
library)             
p   libgtkd3-68                        - gtkd3 for dmd2 (runtime
library)             
p   libgtkd3-69                        - gtkd3 for dmd2 (runtime
library)             
p   libgtkd3-70                        - gtkd3 for dmd2 (runtime
library)             
p   libgtkd3-71                        - gtkd3 for dmd2 (runtime
library)             
p   libgtkd3-72                        - gtkd3 for dmd2 (runtime
library)             
p   libgtkd3-73                        - gtkd3 for dmd2 (runtime
library)             
p   libgtkd3-74                        - gtkd3 for dmd2 (runtime
library)             
p   libgtkd3-75                        - gtkd3 for dmd2 (runtime
library)             
p   libgtkd3-76                        - gtkd3 for dmd2 (runtime
library)             
p   libgtkd3-77                        - gtkd3 for dmd2 (runtime
library)             
p   libgtkd3-78                        - gtkd3 for dmd2 (runtime
library)             
p   libgtkd3-79                        - GtkD3 for DMD2 (runtime
library)             
p   libgtkd3-80                        - GtkD3 for DMD2 (runtime
library)             
p   libgtkd3-81                        - GtkD3 for DMD2 (runtime
library)             
p   libgtkd3-82                        - GtkD3 for DMD2 (runtime
library)             
p   libgtkd3-83                        - GtkD3 for DMD2 (runtime
library)             
p   libgtkd3-84                        - GtkD3 for DMD2 (runtime
library)             
p   libgtkd3-dev                       - GtkD3 for DMD2 (development
files)           
i   libgtkd3-doc                       - GtkD3 for DMD2 (documentation and
examples)  
p   libgtkdatabox-dev                  - Gtk+ library to display large amounts
of nume
p   libgtkdatabox-doc                  - Gtk+ library to display large amounts
of nume
p   libgtkdatabox0                     - Gtk+ library to display large amounts
of nume
p   libgtkdatabox0-glade               - Gtk+ library to display large amounts
of nume
p   libgtkdatabox0-libglade            - Gtk+ library to display large amounts
of nume
p   libgtkdsv-3-0                      - GTK+ syntax highlighting widget - D
bindings 
p   libgtkdsv-3-dev                    - GTK+ syntax highlighting widget -
development

I am using the GtkD package created by the D Debian package people. This is
created using LDC rather than DMD. All the other libgtkd3 packages are ones
build by Jordi Sayol on D-Apt. If you want to use DMD, it is probably best to
install them. Me, I am an LDC oriented person so am happy with the standard
Debian packaged GtkD.

The libgtkd-3-0 package contains just the runtime libraries, or library in
this case. This being Linux libraries are always shared objects (aka DLLs):

> dpkg -L libgtkd-3-0 
/.
/usr
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/libgtkd-3.so.0.8.5
/usr/share
/usr/share/doc
/usr/share/doc/libgtkd-3-0
/usr/share/doc/libgtkd-3-0/changelog.Debian.gz
/usr/share/doc/libgtkd-3-0/changelog.gz
/usr/share/doc/libgtkd-3-0/copyright
/usr/lib/x86_64-linux-gnu/libgtkd-3.so.0

The  libgtkd-3-dev  package contains all the files needed to build code
against GtkD.

 |> dpkg -L libgtkd-3-dev
/.
/usr
/usr/include
/usr/include/d
/usr/include/d/gtkd-3
…
[all the GtkD sources.]
…
/usr/lib
/usr/lib/x86_64-linux-gnu
/usr/lib/x86_64-linux-gnu/pkgconfig
/usr/lib/x86_64-linux-gnu/pkgconfig/gtkd-3.pc
/usr/share
/usr/share/doc
/usr/share/doc/libgtkd-3-dev
/usr/share/doc/libgtkd-3-dev/changelog.Debian.gz
/usr/share/doc/libgtkd-3-dev/changelog.gz
/usr/share/doc/libgtkd-3-dev/copyright
/usr/lib/x86_64-linux-gnu/libgtkd-3.so

The last file here is crucial since it is the file you link your code against
to get the version currently on this system.  The file:

/usr/lib/x86_64-linux-gnu/pkgconfig/gtkd-3.pc

is critical since it tells the compiler where to look for stuff.

|> more /usr/lib/x86_64-linux-gnu/pkgconfig/gtkd-3.pc
Name: GtkD
Description: A D binding and OO wrapper for GTK+.
Version: 3.8.5
Libs: -L-L/usr/lib/x86_64-linux-gnu/ -L-lgtkd-3 -L-ldl
Cflags: -I/usr/include/d/gtkd-3/

> So far, as I said, dmd is working. Up until now, I've avoided dub 
> because, with so many code examples (more than 70 at present) dub 
> would bring in a lot of file/directory clutter.

In this situation, I tend to use SCons as a build manager. I also use Meson,
but the /usr/lib/x86_64-linux-gnu/pkgconfig/gtkd-3.pc is, sadly, inconsistent
with the way Meson works, so you have to use a bit of a hideous hack to get
things working. That is for later not now.

So here is a "Hello World in D" project I have:

|> tree
.
├── cmake-d -> /home/users/russel/Repositories/Git/Forks/CMake-D/cmake-d
├── CMakeLists.txt
├── dub.sdl
├── dub.selections.json
├── meson.build
├── SConstruct
└── source
    ├── gtkd_button.d
    ├── gtkd_label.d
    ├── qtd.d
    ├── SConscript
    └── text.d

1 directory, 11 files

The CMake-D build is broken, so we have to ignore that.

The QtD is a work in progress, that isn't actually progressing. 

Let me point you at https://bitbucket.org/russel/helloworld/src/default/D/
rather than cut and past the SCons files here. The summary is a SCons file is a Python script (Python 3.7 in my case) that calculates a build ADG and then actions any needed changes. The result in this case:

|> scons
scons: Reading SConscript files ...
scons: done reading SConscript files.
scons: Building targets ...
ldc2 -I=. -O -release -I/usr/include/d/gtkd-3/ -c -of=Build_SCons/gtkd_button.o source/gtkd_button.d
ldc2 -of=Build_SCons/gtkd_button -L-L/usr/lib/x86_64-linux-gnu/ Build_SCons/gtkd_button.o -L-lgtkd-3 -L-ldl
ldc2 -I=. -O -release -I/usr/include/d/gtkd-3/ -c -of=Build_SCons/gtkd_label.o source/gtkd_label.d
ldc2 -of=Build_SCons/gtkd_label -L-L/usr/lib/x86_64-linux-gnu/ Build_SCons/gtkd_label.o -L-lgtkd-3 -L-ldl
ldc2 -I=. -O -release -c -of=Build_SCons/text.o source/text.d
ldc2 -of=Build_SCons/text Build_SCons/text.o
scons: done building targets.

The calls to pkg-config have picked up the needed -L-L and -L-l options in
order for it to build.

I had thought the Dub build worked, but it doesn't. :-(

> But you're saying that dub will make it easier to keep up with 
> future changes/updates in all the various bits and bobs, so if 
> that means I finally have to do dub, perhaps someone could point 
> me at a good tutorial for that?

Sort of. Using the Debian packages, things get updated when the packagers
update things. They are usually pretty quick. Using Dub, you have to bit more
hands on given the dependency version in the dub.sdl file.

> Sorry if I sound ungrateful or cranky, but I have a lot on my 
> plate ATM and I'm getting frustrated.

Hopefully the above has helped, do feel free to ask further questions. I am a
day-in, day-out Debian Sid user and so may still be making assumptions tht
aren't working for you…

-- 
Russel.
===========================================
Dr Russel Winder      t: +44 20 7585 2200
41 Buckmaster Road    m: +44 7770 465 077
London SW11 1EN, UK   w: www.russel.org.uk

-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 833 bytes
Desc: This is a digitally signed message part
URL: <http://lists.puremagic.com/pipermail/digitalmars-d-learn/attachments/20190218/f8cc561a/attachment.sig>


More information about the Digitalmars-d-learn mailing list