gtk-rs / gtk

DEPRECATED, use https://github.com/gtk-rs/gtk3-rs repository instead!
https://gtk-rs.org/
MIT License
1.24k stars 82 forks source link

dyld: Library not loaded: /usr/local/opt/gtk+3/lib/libgtk-3.0.dylib #989

Closed huangyehui closed 4 years ago

huangyehui commented 4 years ago
  when I use 'cargo build --release' build exe. I can not excute on anther pc which did not install gtk.The error info showed as title.
  I try to copy all the dependency libraries in the exe`s directory. But still not work.Is someone know the reson?  need help:)
sdroege commented 4 years ago

You need to install GTK into the same directory as on the machine where you built it, or use otool to relocate things. This is unrelated to GTK or the bindings but a generic macOS development question.

Generally it's a better idea to install GTK next to your application so that you can bundle both together and use otool to have the dynamic library loader search for the libraries relative to the executable.

GuillaumeGomez commented 4 years ago

Just installing gtk through homebrew worked fine for me. No idea otherwise.

sdroege commented 4 years ago

Yes but you need to install it via homebrew on both sides then.

huangyehui commented 4 years ago

You need to install GTK into the same directory as on the machine where you built it, or use otool to relocate things. This is unrelated to GTK or the bindings but a generic macOS development question.

Generally it's a better idea to install GTK next to your application so that you can bundle both together and use otool to have the dynamic library loader search for the libraries relative to the executable.

thanks for reply. I am a newbie in rust. I am still confuse that how to produce a release application with gtk in a easy way。A c/c++ application can bundle dynamic lib if lib exist in the same directory . so that the application can run on a pc without install dependency libs。 So I guess gtk lib also can be bundled easily by assign path in cargo.toml. But I have not find the right way. If develop a application with gtk-rs and send it to users. My I have a common way to do that? as I know it is easy to bundle dependency libraries on Android,MFC...

sdroege commented 4 years ago

It's the same with C/C++ on macOS. Linking is by default always with the full absolute path, which you can adjust afterwards with otool.

My suggestion would be to have GTK and its dependencies as part of application installation directory, and adjust the library paths to be relative via otool. That's (from my understanding) the normal approach to do things on macOS.

huangyehui commented 4 years ago

It's the same with C/C++ on macOS. Linking is by default always with the full absolute path, which you can adjust afterwards with otool.

My suggestion would be to have GTK and its dependencies as part of application installation directory, and adjust the library paths to be relative via otool. That's (from my understanding) the normal approach to do things on macOS.

Thansk a lot, I will try :)