简体   繁体   English

Ubuntu:SWT 应用程序无法加载 GTK 库

[英]Ubuntu: SWT App Can't Load GTK Library

I have supplied the Linux SWT jar and packaged my app in Eclipse to include swt.jar inside my app's jar.我提供了 Linux SWT jar 并将我的应用程序打包在 Eclipse 中,以将 swt.jar 包含在我的应用程序 jar 中。 When I try to run it on Ubuntu, I get the following error text (posting only cause):当我尝试在 Ubuntu 上运行它时,我收到以下错误文本(仅发布原因):

Caused by: java.lang.UnsatisfiedLinkError: Could not load SWT library.引起:java.lang.UnsatisfiedLinkError:无法加载 SWT 库。 Reasons:原因:

no swt-pi-gtk-4234 in java.library.path java.library.path 中没有 swt-pi-gtk-4234

no swt-pi-gtk in java.library.path java.library.path 中没有 swt-pi-gtk

/home/nifty/.swt/lib/linux/x86/libswt-pi-gtk-4234.so: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory /home/nifty/.swt/lib/linux/x86/libswt-pi-gtk-4234.so:libgtk-x11-2.0.so.0:无法打开共享对象文件:没有这样的文件或目录

Can't load library: /home/nifty/.swt/lib/linux/x86/libswt-pi-gtk.so无法加载库:/home/nifty/.swt/lib/linux/x86/libswt-pi-gtk.so

This indicates to me it can't load a GTK file, but anything beyond that, and I'm at a loss.这向我表明它无法加载 GTK 文件,但除此之外的任何内容,我都不知所措。 I'm only using Ubuntu to test my app, so I know very little.我只使用 Ubuntu 来测试我的应用程序,所以我知道的很少。

Here is how I fix that missing lib on my Ubuntu 13.10 x86_64: 以下是我在Ubuntu 13.10 x86_64上修复丢失的lib的方法:

java.lang.UnsatisfiedLinkError: Could not load SWT library. java.lang.UnsatisfiedLinkError:无法加载SWT库。 Reasons: /home/ywu/.eclipse/473605238/configuration/org.eclipse.osgi/bundles/361/1/.cp/libswt-pi-gtk-4236.so: libgtk-x11-2.0.so.0: cannot open shared object file: No such file or directory 原因:/home/ywu/.eclipse/473605238/configuration/org.eclipse.osgi/bundles/361/1/.cp/libswt-pi-gtk-4236.so:libgtk-x11-2.0.so.0:不能打开共享对象文件:没有这样的文件或目录

ywu@ywu-HP-8100:~$ aptitude search libgtk2.0-0
    i   libgtk2.0-0                   - GTK+ graphical user interface library                                                         
    p   libgtk2.0-0:i386              - GTK+ graphical user interface library
ywu@ywu-HP-8100:~$ sudo apt-get install libgtk2.0-0:i386

On my 64-bit Debian Wheezy/testing I solved it by doing 在我的64位Debian Wheezy /测试中,我通过这样做解决了它

apt-get install ia32-libs-gtk

( http://www.eclipse.org/forums/index.php/t/262868/ ). http://www.eclipse.org/forums/index.php/t/262868/ )。 If your system isn't a 64-bit system then this suggestion is not applicable. 如果您的系统不是64位系统,则此建议不适用。

With latest Ubuntu (18.10), installing libswt-gtk-3-java fixed it. 使用最新的Ubuntu(18.10),安装libswt-gtk-3-java修复它。 To do so, from a terminal, type the command: sudo apt install libswt-gtk-3-java 为此,请从终端输入命令: sudo apt install libswt-gtk-3-java

For most updated version, I would suggest following link: https://packages.ubuntu.com/search?keywords=swt-gtk 对于大多数更新版本,我建议以下链接: https//packages.ubuntu.com/search?keywords = wtwt -gtk

For more recent releases, if it says it can't find libgtk-3.so.0 , the obvious package you need to apt-get install is libgtk-3-0 . 对于更新的版本,如果它说找不到libgtk-3.so.0 ,那么apt-get install需要的明显包是libgtk-3-0 However, it seems on Ubuntu Zesty (17.04) there isn't such a package, so I needed to switch to Xenial (16.04). 然而,似乎在Ubuntu Zesty(17.04)上没有这样的包,所以我需要切换到Xenial(16.04)。 Artful and later should work too. 狡猾的,后来也应该工作。

Also, the graphical Eclipse Installer won't work without this. 此外,没有它, 图形Eclipse安装程序将无法工作。

这对我在 i386/debian 上使用 docker 有效:

apt-get install libgtk2.0-0 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM