在Linux下部署Qt应用程序

时间:2013-12-05 11:12:08

标签: qt ubuntu deployment

我正在尝试在Ubuntu下部署我的qt应用。 我有Qt5.1.1。库是动态链接的。

在main()

QStringList paths = QCoreApplication::libraryPaths();
paths.append("libs");
paths.append("platform");
paths.append("audio");
paths.append("designer");
paths.append("sqldrivers");
QCoreApplication::setLibraryPaths(paths);

文件夹结构(ls -Rl):

total 3184
drwxr-xr-x 2 viktor viktor    4096 Oct 25 10:09 audio
drwxr-xr-x 2 viktor viktor    4096 Oct 25 10:09 designer
drwxr-xr-x 2 viktor viktor    4096 Dec  5 12:18 libs
drwxr-xr-x 2 viktor viktor    4096 Oct 25 10:09 platforms
drwxr-xr-x 2 viktor viktor    4096 Dec  5 12:18 sqldrivers
-rwxr-xr-x 1 viktor viktor 3237902 Dec  5 13:06 App

./audio:
total 84
-rwxr-xr-x 1 viktor viktor 84564 Aug 27 14:24 libqtmedia_pulse.so

./designer:
total 32
-rwxr-xr-x 1 viktor viktor 14820 Aug 27 14:24 libqdeclarativeview.so
-rwxr-xr-x 1 viktor viktor 15248 Aug 27 14:24 libqwebview.so

./libs:
total 86524
-rwxr-xr-x 1 viktor viktor 22315900 Apr 29  2013 libicudata.so.51
-rwxr-xr-x 1 viktor viktor  2698565 Apr 29  2013 libicui18n.so.51
-rwxr-xr-x 1 viktor viktor  1742896 Apr 29  2013 libicuuc.so.51
-rwxr-xr-x 1 viktor viktor  4721396 Oct 25 10:10 libQt5Core.so.5
-rwxr-xr-x 1 viktor viktor  4629056 Aug 27 14:23 libQt5Gui.so.5
-rwxr-xr-x 1 viktor viktor   874308 Aug 27 14:23 libQt5Multimedia.so.5
-rwxr-xr-x 1 viktor viktor  1406652 Aug 27 14:23 libQt5Network.so.5
-rwxr-xr-x 1 viktor viktor   397104 Aug 27 14:23 libQt5OpenGL.so.5
-rwxr-xr-x 1 viktor viktor   334468 Aug 27 14:23 libQt5PrintSupport.so.5
-rwxr-xr-x 1 viktor viktor  2705336 Aug 27 14:23 libQt5Qml.so.5
-rwxr-xr-x 1 viktor viktor  3285156 Aug 27 14:23 libQt5Quick.so.5
-rwxr-xr-x 1 viktor viktor   224744 Aug 27 14:21 libQt5Sensors.so.5
-rwxr-xr-x 1 viktor viktor   256756 Aug 27 14:23 libQt5Sql.so.5
-rwxr-xr-x 1 viktor viktor  4627352 Aug 27 14:23 libQt5V8.so.5.1.1
-rwxr-xr-x 1 viktor viktor 31642416 Aug 27 14:23 libQt5WebKit.so.5
-rwxr-xr-x 1 viktor viktor   241052 Aug 27 14:23 libQt5WebKitWidgets.so.5
-rwxr-xr-x 1 viktor viktor  6465512 Aug 27 14:23 libQt5Widgets.so.5

./platforms:
total 1500
-rwxr-xr-x 1 viktor viktor  167272 Aug 27 14:24 libqlinuxfb.so
-rwxr-xr-x 1 viktor viktor   30600 Aug 27 14:24 libqminimal.so
-rwxr-xr-x 1 viktor viktor  134012 Aug 27 14:24 libqoffscreen.so
-rwxr-xr-x 1 viktor viktor 1196984 Aug 27 14:24 libqxcb.so

./sqldrivers:
total 732
-rwxr-xr-x 1 viktor viktor 747196 Aug 27 14:24 libqsqlite.so

但是当我尝试运行app时,我得到了:

  加载共享库时出现

错误:libQt5WebKitWidgets.so.5:无法打开共享对象文件:没有这样的文件或目录

1 个答案:

答案 0 :(得分:0)

我不确定,但您可能不仅要附加目录名称,还要附加完整路径。获取应用程序目录,并在其中附加子目录名称。

QString appFilePath = QCoreApplication::applicationFilePath();

QStringList paths = QCoreApplication::libraryPaths();
paths.append(QString("%1/%2").arg(appFilePath).arg("libs"));
paths.append(QString("%1/%2").arg(appFilePath).arg("platform"));
...