simonkrauter / NiGui

Cross-platform desktop GUI toolkit written in Nim
MIT License
718 stars 50 forks source link

"could not load: libgtk-x11-3.0.dylib" on macOS #63

Closed abulka closed 4 years ago

abulka commented 4 years ago

Calc seemed to build ok on Mac, but couldn't run because of a missing libgtk library. Is there any solution for this?

Hint:  [Link]
Hint: operation successful (44662 lines compiled; 4.632 sec total; 72.336MiB peakmem; Debug Build) [SuccessX]
Hint: /Users/Andy/Devel/nim_demos/NiCalc/src/NiCalc  [Exec]
could not load: libgtk-x11-3.0.dylib
compile with -d:nimDebugDlOpen for more information
Error: execution of an external program failed: '/Users/Andy/Devel/nim_demos/NiCalc/src/NiCalc '
simonkrauter commented 4 years ago

I moved this issue to the NiGui repo, because it's relevant for all applications build on NiGui. There is no native macOS support yet, but with Gtk it should work. I don't have macOS and I don't know how to install Gtk there. Maybe any macOS user can help.

If it does not find the libraries, maybe the names have to be adjusted in this code block:

when defined(windows):
  const libgtk3Path* = "libgtk-3-0.dll"
elif defined(gtk_quartz):
  const libgtk3Path* = "libgtk-3.0.dylib"
elif defined(macosx):
  const libgtk3Path* = "libgtk-x11-3.0.dylib"
else:
  const libgtk3Path* = "libgtk-3.so(|.0)"
dcurrie commented 4 years ago

Using homebrew the gtk+3 library is installed in /usr/local/Cellar/gtk+3/3.24.9/lib/libgtk-3.0.dylib

Somehow, NiGui seems to find it if I build with -d:gtk_quartz as in nim c -d:gtk_quartz -r nidraw.nim

deeuu commented 4 years ago

Can confirm -d:gtk_quartz works on macOS Catalina.

simonkrauter commented 4 years ago

I changed the filename used on macOS to the one used for -d:gtk_quartz: Now it should find the library without compiling with -d:gtk_quartz. I assume the other filename is not needed. If any problem occurs, please reopen.