本文共 2745 字,大约阅读时间需要 9 分钟。
最近用到一个和同事合作的项目,也在eclipse下开发,工程代码比较多,移植时碰到一些问题,与大家分享一下: 原因:工程编译时很多地方用到其他目录下的依赖文件,依赖一个指定的用户ubuntu,而这个我的eclipse安装使用用户不同,该代码的级联问题再多,所以决定在本机下创建ubuntu用户来解决。 步骤: 1.创建新用户 ubuntu,在其主目录 /home/ubuntu/ 下面创建 workspace目录; 2.注销切换用户,用新的ubuntu用户登录; 3.打开eclipse,发现打不开,报错,提示进入/.eclipse/org.eclipse.platform_3.7.0_155965261/configuration/1348562618674.log 查看错误日志,gedit 1348562699374.logOK ,报错信息如下:!ENTRY org.eclipse.osgi 4 0 2012-09-25 16:45:03.318!MESSAGE Application error!STACK 1java.lang.UnsatisfiedLinkError: Could not load SWT library. Reasons: no swt-gtk-3740 in java.library.path no swt-gtk in java.library.path Can't load library: /home/ubuntu/.swt/lib/linux/x86/libswt-gtk-3740.so Can't load library: /home/ubuntu/.swt/lib/linux/x86/libswt-gtk.so at org.eclipse.swt.internal.Library.loadLibrary(Library.java:285) at org.eclipse.swt.internal.Library.loadLibrary(Library.java:194) at org.eclipse.swt.internal.C.<clinit>(C.java:21) at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:63) at org.eclipse.swt.internal.Converter.wcsToMbcs(Converter.java:54) at org.eclipse.swt.widgets.Display.<clinit>(Display.java:132) at org.eclipse.ui.internal.Workbench.createDisplay(Workbench.java:695) at org.eclipse.ui.PlatformUI.createDisplay(PlatformUI.java:161) at org.eclipse.ui.internal.ide.application.IDEApplication.createDisplay(IDEApplication.java:153) at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:95) at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110) at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344) at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179) at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57) at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) at java.lang.reflect.Method.invoke(Method.java:601) at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622) at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577) at org.eclipse.equinox.launcher.Main.run(Main.java:1410)信息挺多,大致意思就是 eclipse启动时需要加载的一些库在 /home/ubuntu/.swt/lib/linux/x86/ 下找不到,事实上ecilpse运行时在用户的主目录下都会产生2个目录,.eclipse和 .swt ;
.swt就是存放运行时库的。
OK ,文件找到就好解决了,找到原来用户目录下的 .swt/lib/linux/x86/ 所有文件,copy到当前目录,在运行eclipse就OK了;问题2:运行起来后发现原有的C/C++工程无法编译,文件图标全都是gedit打开风格,看来时CDT插件的问题,安装CDT插件:help ---》install new software 打开如下地址:CDT - http://download.eclipse.org/tools/cdt/releases/helios,安装完成重启就OK 了。 转载地址:http://pjgab.baihongyu.com/