如何从Qt项目

时间:2016-07-31 10:51:03

标签: qt ubuntu snapcraft

这是我第一次将程序构建到SNAP包中。我想让我的程序更容易访问。 构建没有问题。 但是libqtnetwor5看不到一些需要的库。在下面,您可以看到所有日志和配置的描述。

项目树:

tree
.
├── bin
│   └── ProjectTimer
├── setup
│   └── gui
│       └── icon.png
├── snapcraft.yaml
└── timerproject_1.0_amd64.snap

3 directories, 4 files

snapcraft.yaml

name: timerproject
version: "1.0"
summary: timer
description: |
    Application for time-management
confinement: strict
architectures: [amd64]

apps:
    timerproject:
        command: desktop-launch ProjectTimer
        plugs: ['home', 'unity7', 'x11', 'network']

parts:
    timerproject:
        plugin: copy
        files:
            bin/ProjectTimer : usr/bin/ProjectTimer
            setup/gui/icon.png : usr/share/icons/timer.ico

    integration:
        plugin: nil
        stage-packages:
            - libc-bin
            - libqt5network5
        after: [desktop/qt5]

ldd ProjectTimer显示程序需要的所有libreries:

ldd bin/ProjectTimer
    linux-vdso.so.1 =>  (0x00007fff1f1fc000)
    libQt5QuickControls2.so.5 => /media/free/Qt5.7.0/5.7/gcc_64/lib/libQt5QuickControls2.so.5 (0x00007f5d2ad62000)
    libQt5Quick.so.5 => /media/free/Qt5.7.0/5.7/gcc_64/lib/libQt5Quick.so.5 (0x00007f5d2a772000)
    libQt5Widgets.so.5 => /media/free/Qt5.7.0/5.7/gcc_64/lib/libQt5Widgets.so.5 (0x00007f5d29f22000)
    libQt5Gui.so.5 => /media/free/Qt5.7.0/5.7/gcc_64/lib/libQt5Gui.so.5 (0x00007f5d2977a000)
    libQt5Qml.so.5 => /media/free/Qt5.7.0/5.7/gcc_64/lib/libQt5Qml.so.5 (0x00007f5d2917a000)
    libQt5Core.so.5 => /media/free/Qt5.7.0/5.7/gcc_64/lib/libQt5Core.so.5 (0x00007f5d28a5a000)
    libstdc++.so.6 => /usr/lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f5d286b2000)
    libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f5d2849a000)
    libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f5d280ca000)
    libQt5Network.so.5 => /media/free/Qt5.7.0/5.7/gcc_64/lib/libQt5Network.so.5 (0x00007f5d27d6a000)
    libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f5d27b4a000)
    libQt5QuickTemplates2.so.5 => /media/free/Qt5.7.0/5.7/gcc_64/lib/libQt5QuickTemplates2.so.5 (0x00007f5d27882000)
    libGL.so.1 => /usr/lib/nvidia-361/libGL.so.1 (0x00007f5d275f2000)
    libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f5d272e2000)
    libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f5d270c2000)
    librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f5d26eba000)
    /lib64/ld-linux-x86-64.so.2 (0x0000562df3108000)
    libicui18n.so.56 => /media/free/Qt5.7.0/5.7/gcc_64/lib/libicui18n.so.56 (0x00007f5d26a1a000)
    libicuuc.so.56 => /media/free/Qt5.7.0/5.7/gcc_64/lib/libicuuc.so.56 (0x00007f5d26662000)
    libicudata.so.56 => /media/free/Qt5.7.0/5.7/gcc_64/lib/libicudata.so.56 (0x00007f5d24c7a000)
    libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f5d24a72000)
    libgthread-2.0.so.0 => /usr/lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f5d2486a000)
    libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f5d24552000)
    libGLX.so.0 => /usr/lib/nvidia-361/libGLX.so.0 (0x00007f5d2431a000)
    libGLdispatch.so.0 => /usr/lib/nvidia-361/libGLdispatch.so.0 (0x00007f5d24032000)
    libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f5d23dc2000)
    libX11.so.6 => /usr/lib/x86_64-linux-gnu/libX11.so.6 (0x00007f5d23a82000)
    libXext.so.6 => /usr/lib/x86_64-linux-gnu/libXext.so.6 (0x00007f5d2386a000)
    libxcb.so.1 => /usr/lib/x86_64-linux-gnu/libxcb.so.1 (0x00007f5d23642000)
    libXau.so.6 => /usr/lib/x86_64-linux-gnu/libXau.so.6 (0x00007f5d2343a000)
    libXdmcp.so.6 => /usr/lib/x86_64-linux-gnu/libXdmcp.so.6 (0x00007f5d23232000)

如果我开始编程,我会看到消息:     timerproject     ProjectTimer:/snap/timerproject/x1/usr/lib/x86_64-linux-gnu/libQt5Network.so.5:版本Qt_5' not found (required by /snap/timerproject/x1/media/free/Qt5.7.0/5.7/gcc_64/lib/libQt5Quick.so.5) ProjectTimer: /snap/timerproject/x1/usr/lib/x86_64-linux-gnu/libQt5Network.so.5: version Qt_5'未找到         (需要/snap/timerproject/x1/media/free/Qt5.7.0/5.7/gcc_64/lib/libQt5Qml.so.5)

这是SNAP包的库:

ls -l /snap/timerproject/x1/media/free/Qt5.7.0/5.7/gcc_64/lib

-rwxr-xr-x 1 root root 25047100 янв 28  2016 libicudata.so.56
-rwxr-xr-x 1 root root  3374854 янв 28  2016 libicui18n.so.56
-rwxr-xr-x 1 root root  2070162 янв 28  2016 libicuuc.so.56
-rwxr-xr-x 1 root root  5339752 июл 30 16:45 libQt5Core.so.5
-rwxr-xr-x 1 root root  5909528 июн 10 12:10 libQt5Gui.so.5
-rwxr-xr-x 1 root root  4156520 июн 11 17:18 libQt5Qml.so.5
-rwxr-xr-x 1 root root    78696 июн 13 00:46 libQt5QuickControls2.so.5
-rwxr-xr-x 1 root root  4125768 июн 11 17:18 libQt5Quick.so.5
-rwxr-xr-x 1 root root   807600 июн 13 00:46 libQt5QuickTemplates2.so.5
-rwxr-xr-x 1 root root  6614408 июн 10 12:10 libQt5Widgets.so.5

我的系统有标准库Qt:

ls -l /usr/lib/x86_64-linux-gnu/libQt5*
-rw-r--r-- 1 root root     1014 май  2 15:37 /usr/lib/x86_64-linux-gnu/libQt5Core.prl
lrwxrwxrwx 1 root root       19 май  2 15:39 /usr/lib/x86_64-linux-gnu/libQt5Core.so -> libQt5Core.so.5.5.1
lrwxrwxrwx 1 root root       19 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5Core.so.5 -> libQt5Core.so.5.5.1
lrwxrwxrwx 1 root root       19 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.5 -> libQt5Core.so.5.5.1
-rw-r--r-- 1 root root  5052920 май  2 15:41 /usr/lib/x86_64-linux-gnu/libQt5Core.so.5.5.1
-rw-r--r-- 1 root root     1008 май  2 15:37 /usr/lib/x86_64-linux-gnu/libQt5DBus.prl
lrwxrwxrwx 1 root root       19 май  2 15:39 /usr/lib/x86_64-linux-gnu/libQt5DBus.so -> libQt5DBus.so.5.5.1
lrwxrwxrwx 1 root root       19 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5DBus.so.5 -> libQt5DBus.so.5.5.1
lrwxrwxrwx 1 root root       19 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5DBus.so.5.5 -> libQt5DBus.so.5.5.1
-rw-r--r-- 1 root root   509456 май  2 15:41 /usr/lib/x86_64-linux-gnu/libQt5DBus.so.5.5.1
lrwxrwxrwx 1 root root       23 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5Feedback.so.5 -> libQt5Feedback.so.5.0.0
lrwxrwxrwx 1 root root       23 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5Feedback.so.5.0 -> libQt5Feedback.so.5.0.0
-rw-r--r-- 1 root root    52144 мар 14 14:20 /usr/lib/x86_64-linux-gnu/libQt5Feedback.so.5.0.0
-rw-r--r-- 1 root root     1039 май  2 15:37 /usr/lib/x86_64-linux-gnu/libQt5Gui.prl
lrwxrwxrwx 1 root root       18 май  2 15:39 /usr/lib/x86_64-linux-gnu/libQt5Gui.so -> libQt5Gui.so.5.5.1
lrwxrwxrwx 1 root root       18 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5 -> libQt5Gui.so.5.5.1
lrwxrwxrwx 1 root root       18 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.5 -> libQt5Gui.so.5.5.1
-rw-r--r-- 1 root root  5514016 май  2 15:41 /usr/lib/x86_64-linux-gnu/libQt5Gui.so.5.5.1
-rw-r--r-- 1 root root     1002 май  2 15:37 /usr/lib/x86_64-linux-gnu/libQt5Network.prl
lrwxrwxrwx 1 root root       22 май  2 15:39 /usr/lib/x86_64-linux-gnu/libQt5Network.so -> libQt5Network.so.5.5.1
lrwxrwxrwx 1 root root       22 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5Network.so.5 -> libQt5Network.so.5.5.1
lrwxrwxrwx 1 root root       22 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5Network.so.5.5 -> libQt5Network.so.5.5.1
-rw-r--r-- 1 root root  1412480 май  2 15:41 /usr/lib/x86_64-linux-gnu/libQt5Network.so.5.5.1
-rw-r--r-- 1 root root  1266500 май  2 15:41 /usr/lib/x86_64-linux-gnu/libQt5OpenGLExtensions.a
-rw-r--r-- 1 root root     1056 май  2 15:37 /usr/lib/x86_64-linux-gnu/libQt5OpenGLExtensions.prl
lrwxrwxrwx 1 root root       21 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5OpenGL.so.5 -> libQt5OpenGL.so.5.5.1
lrwxrwxrwx 1 root root       21 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5OpenGL.so.5.5 -> libQt5OpenGL.so.5.5.1
-rw-r--r-- 1 root root   362752 май  2 15:41 /usr/lib/x86_64-linux-gnu/libQt5OpenGL.so.5.5.1
lrwxrwxrwx 1 root root       18 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5 -> libQt5Qml.so.5.5.1
lrwxrwxrwx 1 root root       18 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5.5 -> libQt5Qml.so.5.5.1
-rw-r--r-- 1 root root  4358744 апр 12 13:00 /usr/lib/x86_64-linux-gnu/libQt5Qml.so.5.5.1
lrwxrwxrwx 1 root root       20 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5 -> libQt5Quick.so.5.5.1
lrwxrwxrwx 1 root root       20 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5.5 -> libQt5Quick.so.5.5.1
-rw-r--r-- 1 root root  3991248 апр 12 13:00 /usr/lib/x86_64-linux-gnu/libQt5Quick.so.5.5.1
lrwxrwxrwx 1 root root       24 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5QuickTest.so.5 -> libQt5QuickTest.so.5.5.1
lrwxrwxrwx 1 root root       24 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5QuickTest.so.5.5 -> libQt5QuickTest.so.5.5.1
-rw-r--r-- 1 root root   119232 апр 12 13:00 /usr/lib/x86_64-linux-gnu/libQt5QuickTest.so.5.5.1
lrwxrwxrwx 1 root root       21 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5 -> libQt5WebKit.so.5.5.1
lrwxrwxrwx 1 root root       21 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5.5 -> libQt5WebKit.so.5.5.1
-rw-r--r-- 1 root root 37857816 ноя 30  2015 /usr/lib/x86_64-linux-gnu/libQt5WebKit.so.5.5.1
lrwxrwxrwx 1 root root       28 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5WebKitWidgets.so.5 -> libQt5WebKitWidgets.so.5.5.1
lrwxrwxrwx 1 root root       28 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5WebKitWidgets.so.5.5 -> libQt5WebKitWidgets.so.5.5.1
-rw-r--r-- 1 root root   282016 ноя 30  2015 /usr/lib/x86_64-linux-gnu/libQt5WebKitWidgets.so.5.5.1
-rw-r--r-- 1 root root     1059 май  2 15:37 /usr/lib/x86_64-linux-gnu/libQt5Widgets.prl
lrwxrwxrwx 1 root root       22 май  2 15:39 /usr/lib/x86_64-linux-gnu/libQt5Widgets.so -> libQt5Widgets.so.5.5.1
lrwxrwxrwx 1 root root       22 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5 -> libQt5Widgets.so.5.5.1
lrwxrwxrwx 1 root root       22 июл 29 22:58 /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.5 -> libQt5Widgets.so.5.5.1
-rw-r--r-- 1 root root  6861328 май  2 15:41 /usr/lib/x86_64-linux-gnu/libQt5Widgets.so.5.5.1

也许有人可以理解错误在哪里?或者也许有人可以告诉我如何更好地处理库(我的项目没有使用系统库) 最后一个问题,但并非最不重要的是,有人知道如何构建像这样的Qt项目吗?

1 个答案:

答案 0 :(得分:0)

问题是你要从自己的版本和你的发行版(可能是Ubuntu)中混合Qt库。你正在构建的二进制文件取决于一个Qt库(你可以从你自己的Qt构建中获得),而这一个依赖于你从Ubuntu获得的另一个Qt库。所以这个问题的解决方案是只为Qt库使用一个源。

我可能会去分发库,除非有一些非常具体的原因使用你自己的。要这样做,您需要修复二进制编译(目前没有足够的详细信息),以便不与您的库(-I-L标记,-rpath和类似的事情),其他一切都应该自动完成。

要打包自己的库,您需要使用-rpath标志构建它们,以便在库目录中也可以解析一个库的依赖关系。从我看来,snapcraft应该能够在这种情况下选择它们。