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

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/13630627/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-31 13:26:45  来源:igfitidea点击:

Ubuntu: SWT App Can't Load GTK Library

javalinuxubuntujarswt

提问by Nifty255

I have supplied the Linux SWT jar and packaged my app in Eclipse to include swt.jar inside my app's jar. When I try to run it on Ubuntu, I get the following error text (posting only cause):

我提供了 Linux SWT jar 并将我的应用程序打包在 Eclipse 中,以将 swt.jar 包含在我的应用程序 jar 中。当我尝试在 Ubuntu 上运行它时,我收到以下错误文本(仅发布原因):

Caused by: java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons:

no swt-pi-gtk-4234 in java.library.path

no swt-pi-gtk in java.library.path

/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

Can't load library: /home/nifty/.swt/lib/linux/x86/libswt-pi-gtk.so

引起:java.lang.UnsatisfiedLinkError:无法加载 SWT 库。原因:

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

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

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

无法加载库:/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. I'm only using Ubuntu to test my app, so I know very little.

这向我表明它无法加载 GTK 文件,但除此之外的任何内容,我都不知所措。我只使用 Ubuntu 来测试我的应用程序,所以我知道的很少。

回答by ywu

Here is how I fix that missing lib on my Ubuntu 13.10 x86_64:

这是我在 Ubuntu 13.10 x86_64 上修复丢失的库的方法:

java.lang.UnsatisfiedLinkError: Could not load SWT library. 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

java.lang.UnsatisfiedLinkError:无法加载 SWT 库。原因:/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

回答by Orjan

On my 64-bit Debian Wheezy/testing I solved it by doing

在我的 64 位 Debian Wheezy/testing 上,我解决了这个问题

apt-get install ia32-libs-gtk

(http://www.eclipse.org/forums/index.php/t/262868/). If your system isn't a 64-bit system then this suggestion is not applicable.

http://www.eclipse.org/forums/index.php/t/262868/)。如果您的系统不是 64 位系统,则此建议不适用。

回答by Mohamed El-Beltagy

With latest Ubuntu (18.10), installing libswt-gtk-3-javafixed it. To do so, from a terminal, type the command: sudo apt install libswt-gtk-3-java

使用最新的 Ubuntu (18.10),安装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=swt-gtk

回答by Yushin Washio

For more recent releases, if it says it can't find libgtk-3.so.0, the obvious package you need to apt-get installis 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). Artful and later should work too.

对于较新的版本,如果它说找不到libgtk-3.so.0,则您需要的明显软件包apt-get installlibgtk-3-0。但是,在 Ubuntu Zesty (17.04) 上似乎没有这样的包,所以我需要切换到 Xenial (16.04)。巧妙,后来也应该工作。

Also, the graphical Eclipse Installerwon't work without this.

此外,没有这个图形 Eclipse 安装程序将无法工作。