www.digitalmars.com         C & C++   DMDScript  

digitalmars.D.learn - Request some GtkD Assistance

reply Andrew Edwards <edwards.ac gmail.com> writes:
Good day all,

I've installed Gtk+ and GtkD on my MacBookPro which is running 
macOS Mojave but am having some issues linking to and using it. 
Any assistance to resolve this is appreciated.

Steps taken:

1. Install Gtk+

       brew install gtk+

2. Build and install GtkD-3.8.5

      unzip GtkD-3.8.5.zip
      copy gtkd folder to dmd/osx/src/
      make
      copy libgtkd-3.a to dmd/osx/lib/

3. Update dmd.conf

      add -I% P%/../../src/gtkd to DFLAGS

Problems encountered:

1. Unable to find the lib

(dmd-2.085.0)BMP:model edwarac$ dmd -de -w -Llibgtkd-3.a nufsaid
ld: file not found: libgtkd-3.a
clang: error: linker command failed with exit code 1 (use -v to 
see invocation)
Error: linker exited with status 1

Not sure why I'm receiving this first error since the file is 
stored alongside the libphobos2.a which the linker doesn't have 
any issues locating. If copy the file to the local directory, 
linking completes without any further errors.

2. Unable to find libgtkd-3.dylib

      (dmd-2.085.0)Andrews-MBP:model edwarac$ ./nufsaid
      object.Exception generated/gtkd/gtkd/Loader.d(125): Library 
load failed (libgdk-3.0.dylib): dlopen(libgdk-3.0.dylib, 258): 
image not found

Not sure what's going on here at all. This file was not created 
when I built GtkD. Where do I find it, or how do I create it?

--Andrew
Mar 26
parent reply Nicholas Wilson <iamthewilsonator hotmail.com> writes:
On Wednesday, 27 March 2019 at 06:55:53 UTC, Andrew Edwards wrote:
 Good day all,

 I've installed Gtk+ and GtkD on my MacBookPro which is running 
 macOS Mojave but am having some issues linking to and using it. 
 Any assistance to resolve this is appreciated.

 Steps taken:

 1. Install Gtk+

       brew install gtk+

 2. Build and install GtkD-3.8.5

      unzip GtkD-3.8.5.zip
      copy gtkd folder to dmd/osx/src/
      make
      copy libgtkd-3.a to dmd/osx/lib/

 3. Update dmd.conf

      add -I% P%/../../src/gtkd to DFLAGS

 Problems encountered:

 1. Unable to find the lib

 (dmd-2.085.0)BMP:model edwarac$ dmd -de -w -Llibgtkd-3.a nufsaid
 ld: file not found: libgtkd-3.a
 clang: error: linker command failed with exit code 1 (use -v to 
 see invocation)
 Error: linker exited with status 1

 Not sure why I'm receiving this first error since the file is 
 stored alongside the libphobos2.a which the linker doesn't have 
 any issues locating. If copy the file to the local directory, 
 linking completes without any further errors.

 2. Unable to find libgtkd-3.dylib

      (dmd-2.085.0)Andrews-MBP:model edwarac$ ./nufsaid
      object.Exception generated/gtkd/gtkd/Loader.d(125): 
 Library load failed (libgdk-3.0.dylib): 
 dlopen(libgdk-3.0.dylib, 258): image not found

 Not sure what's going on here at all. This file was not created 
 when I built GtkD. Where do I find it, or how do I create it?

 --Andrew
 dmd -de -w -Llibgtkd-3.a nufsaid
try dmd -de -w -lgtkd-3 nufsaid or dmd -de -w -L/path/to/lib nufsaid
 dlopen(libgdk-3.0.dylib, 258): image not found
it that a typo? gdk not gtk? Regardless gtkD is bindings to gtk which are separate, make sure you have gtk installed and in your path.
Mar 27
parent reply Andrew Edwards <edwards.ac gmail.com> writes:
On Wednesday, 27 March 2019 at 09:07:37 UTC, Nicholas Wilson 
wrote:
 On Wednesday, 27 March 2019 at 06:55:53 UTC, Andrew Edwards 
 wrote:

 dmd -de -w -Llibgtkd-3.a nufsaid
try dmd -de -w -lgtkd-3 nufsaid
No. That did not work.
 dmd -de -w -L/path/to/lib nufsaid
This would is already included in dlang.conf no? Yes furnishing an explicit path works. dmd -de -w -L/Users/edwarac/dlang/dmd-2.085.0/osx/lib/libgtkd-3.a nufsaid But why do I need to do that if it's sitting right next to phobos and DMD is already searching that directory for libraries?
 dlopen(libgdk-3.0.dylib, 258): image not found
it that a typo? gdk not gtk?
No. This i correct.
 Regardless gtkD is bindings to gtk which are separate, make 
 sure you have gtk installed and in your path.
gtk was the first think I installed, no issues there. I have found a solution to this. brew install gdk+3 does the trick. Thank you.
Mar 27
parent reply Mike Wey <mike-wey example.com> writes:
On 27-03-2019 11:01, Andrew Edwards wrote:
 This would is already included in dlang.conf no? Yes furnishing an 
 explicit path works.
 dmd -de -w -L/Users/edwarac/dlang/dmd-2.085.0/osx/lib/libgtkd-3.a nufsaid
 
 But why do I need to do that if it's sitting right next to phobos and 
 DMD is already searching that directory for libraries?
That because of the way the dmd and the linker interpret the arguments. -L tell dmd to pass the command that follows to the linker. To tell the linker to link with a library in a known location you would use the -l flag. For the value passed to -l the linker will prefix `lib` and postfix `.so` `.a`. So the following should work properly: `dmd -de -w -L-lgtkd-3 nufsaid' -- Mike Wey
Mar 27
parent Andrew Edwards <edwards.ac gmail.com> writes:
On Wednesday, 27 March 2019 at 19:18:17 UTC, Mike Wey wrote:
 That because of the way the dmd and the linker interpret the 
 arguments.

 -L tell dmd to pass the command that follows to the linker.
 To tell the linker to link with a library in a known location 
 you would use the -l flag.

 For the value passed to -l the linker will prefix `lib` and 
 postfix `.so` `.a`.

 So the following should work properly:
 `dmd -de -w -L-lgtkd-3 nufsaid'
Thank you very much Mike. Works like a charm. Also found out that pragma(lib, "gtlkd-3") does the trick as well. --Andrew
Mar 28