Qt app with no-system-libraries and without


#21

@Lin-Buo-Ren

I decided to try to build application from the Qt libraries in the system.

name: managetime
version: "0.1.0"
summary: timer
description: |
    Application for time management
confinement: strict
architectures: [amd64]
grade: stable

apps:
    managetime:
        command: desktop-launch ${SNAP}/bin/projecttimer
        plugs: [home, unity7, x11, opengl, pulseaudio, wayland, network, desktop, desktop-legacy]
        environment:
            DISABLE_WAYLAND: 1
parts:
    managetime:
        plugin: cmake
        configflags:
        - -DCMAKE_BUILD_TYPE=Release
        - -DCMAKE_INSTALL_PREFIX=/usr
        build-packages:
            - qttools5-dev
            - build-essential
            - qtdeclarative5-dev
            - libqt5svg5-dev
            - qttools5-dev-tools
            - libqt5xmlpatterns5-dev
            - libgles2-mesa-dev
            - qtquickcontrols2-5-dev
        stage-packages:
            - libqt5widgets5
            - libqt5qml5
            - libqt5quick5
            - libqt5quickwidgets5
            - libqt5quickcontrols2-5
            - qml-module-qtquick-controls2
            - qtwayland5
            - libgl1-mesa-dev
            - libgl1-mesa-dri
            - libgl1-mesa-glx
            - libxkbcommon0
        stage:
            - -usr/share/pkgconfig
        after: [desktop-qt5]

And it seems like the application is compiled, but I see an error.
I can not understand what she points

-- Build files have been written to: /media/free/Projects_SCV/projecttimer/parts/managetime/build
make -j12
Scanning dependencies of target projecttimer_autogen
[  6%] Automatic MOC and RCC for target projecttimer
[  6%] Built target projecttimer_autogen
[ 13%] Generating qrc_image.cpp
[ 20%] Generating qrc_translations.cpp
[ 26%] Generating qrc_audio.cpp
[ 33%] Generating qrc_qml.cpp
Scanning dependencies of target projecttimer
[ 40%] Building CXX object CMakeFiles/projecttimer.dir/Sources/qmltranslator.cpp.o
[ 46%] Building CXX object CMakeFiles/projecttimer.dir/Sources/circletimer.cpp.o
[ 53%] Building CXX object CMakeFiles/projecttimer.dir/Sources/SystemTray.cpp.o
[ 66%] Building CXX object CMakeFiles/projecttimer.dir/qrc_translations.cpp.o
[ 66%] Building CXX object CMakeFiles/projecttimer.dir/qrc_qml.cpp.o
[ 73%] Building CXX object CMakeFiles/projecttimer.dir/main.cpp.o
[ 80%] Building CXX object CMakeFiles/projecttimer.dir/qrc_image.cpp.o
[ 86%] Building CXX object CMakeFiles/projecttimer.dir/qrc_audio.cpp.o
[ 93%] Building CXX object CMakeFiles/projecttimer.dir/projecttimer_autogen/mocs_compilation.cpp.o
[100%] Linking CXX executable projecttimer
[100%] Built target projecttimer
make install DESTDIR=/media/free/Projects_SCV/projecttimer/parts/managetime/install
make: *** There is no rule for assembly purpose «install».  stop.
Failed to run 'make install DESTDIR=/media/free/Projects_SCV/projecttimer/parts/managetime/install' for 'managetime': Exited with code 2.
Verify that the part is using the correct parameters and try again.

#22

And I wonder what if I use the qmake, I see another type of error.

Priming desktop-qt5 
Files from the build host were migrated into the snap to satisfy dependencies that would otherwise not be met. This feature will be removed in a future release. If these libraries are needed in the final snap, ensure that the following are either satisfied by a stage-packages entry or through a part:
usr/lib/x86_64-linux-gnu/libXcursor.so.1
usr/lib/x86_64-linux-gnu/libXinerama.so.1
usr/lib/x86_64-linux-gnu/libXrandr.so.2
usr/lib/x86_64-linux-gnu/libatk-1.0.so.0
usr/lib/x86_64-linux-gnu/libgdk-x11-2.0.so.0
usr/lib/x86_64-linux-gnu/libgtk-x11-2.0.so.0
The linker version '2.23' used by the base 'core' is incompatible with files in this snap:
    /media/free/Projects_SCV/projecttimer/prime/lib/x86_64-linux-gnu/libbsd.so.0.8.7 (2.25)
    /media/free/Projects_SCV/projecttimer/prime/lib/x86_64-linux-gnu/libexpat.so.1.6.7 (2.25)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/dri/i915_dri.so (2.27)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/dri/i965_dri.so (2.27)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/dri/kms_swrast_dri.so (2.27)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/dri/nouveau_dri.so (2.27)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/dri/nouveau_vieux_dri.so (2.27)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/dri/r200_dri.so (2.27)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/dri/r300_dri.so (2.27)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/dri/r600_dri.so (2.27)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/dri/radeon_dri.so (2.27)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/dri/radeonsi_dri.so (2.27)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/dri/swrast_dri.so (2.27)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/dri/virtio_gpu_dri.so (2.27)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/dri/vmwgfx_dri.so (2.27)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/libQt5Core.so.5.11.2 (2.25)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/libexpatw.so.1.6.7 (2.25)
    /media/free/Projects_SCV/projecttimer/prime/usr/lib/x86_64-linux-gnu/libxshmfence.so.1.0.0 (2.27)

#23

Have you tried using snapcraft cleanbuild? This will build your code in a container with the correct library versions, which should avoid the “linker version” errors you mentioned.


#24

Yes, I tried to pack this way. I see very strange errors:
At the beginning of the assembly it cursed that he could not find such packages:
- qtquickcontrols2-5-dev
- libqt5quickcontrols2-5
- qml-module-qtquick-controls2

Next error

CMake Error at CMakeLists.txt:15 (find_package):
  By not providing "FindQt5QuickControls2.cmake" in CMAKE_MODULE_PATH this
  project has asked CMake to find a package configuration file provided by
  "Qt5QuickControls2", but CMake did not find one.

  Could not find a package configuration file provided by "Qt5QuickControls2"
  with any of the following names:

    Qt5QuickControls2Config.cmake
    qt5quickcontrols2-config.cmake

  Add the installation prefix of "Qt5QuickControls2" to CMAKE_PREFIX_PATH or
  set "Qt5QuickControls2_DIR" to a directory containing one of the above
  files.  If "Qt5QuickControls2" provides a separate development package or
  SDK, be sure it has been installed.


-- Configuring incomplete, errors occurred!
See also "/root/build_managetime/parts/managetime/build/CMakeFiles/CMakeOutput.log".
Failed to run 'cmake /root/build_managetime/parts/managetime/src -DCMAKE_INSTALL_PREFIX= -DCMAKE_BUILD_TYPE=Release -DCMAKE_INSTALL_PREFIX=/usr -DCMAKE_PREFIX_PATH=/media/free/Qt/5.11.0/gcc_64/lib/cmake/' for 'managetime': Exited with code 1.
Verify that the part is using the correct parameters and try again.                                                                                                                                                                                
Error: not found

Why when I just want to make a package through cmake, then everything is fine, all the packages are seen, the application is being build, and then through snapcraft it cannot see something?


#25

When you run snapcraft cleanbuild, your snap is built in a minimal container. So if your project doesn’t declare its dependencies, you can get problems like this.

The desktop-qt5 makes sure enough is installed for a Qt5GUI program, but doesn’t ensure the full QML stack is available. So you’ll probably need to manually pull in a few extra packages via build-packages and stage-packages.

My guess is that you’d want:

build-packages:
 - qtdeclarative5-dev
 - qtquickcontrols2-5-dev
stage-packages:
 - libqt5quickcontrols2-5
 - qml-module-qtquick-controls2

#26

I have already shown how the snapcraft.yaml file looks.
If I try to build a package like this, I get a strange error:

Downloading parts list|                                                                                                                                                                                                                            
Could not find a required package in 'build-packages': qtquickcontrols2-5-dev
Error: not found
Stopping local:snapcraft-nicely-amused-martin
An error occurred when trying to copy files using 'lxd': returned exit code 1.

#27

Please ensure the package is in the Ubuntu Packages Search and is in the Ubuntu release you’re targeting.


#28

Yes, this file is exists in the repository Ubuntu 18.04. I use KDE Neon 5.14, and it is also exists too.


#29

you need to use package names that exist in Ubuntu 16.04.


#30

Ubuntu 16.04 don’t have package qtquickcontrols2-5-dev, only qtquick1-5-dev
But I use in my app quickcontrols2. I need this particular package. Ubuntu 16.04 useless to me.


#31

I have seen some people have success by building on KDE Neon 16.04 which has newer Qt libraries from the KDE Neon repositories. Perhaps you could try that.


#32

You understand what I need to do to do this?) I need to find the KDE Neon iso before switching to 18.04 and install another system). This is something very stupid.

There are 2 solutions to the problem,
1: to understand why at 18.04 I can not build a snap with the necessary packages that are present in the system.
2: build the application separately and collect package with the necessary dependencies.
In the second case, I did almost everything, but there is some kind of dependence that I could not solve.
I wrote about this a little higher in history.


#33

It was merely one option I offered.

You can actually build on 18.04 too. Using snapcraft 3.0 from the candidate channel, and specifying base: core18 in your snapcraft.yaml


#34

Thanks for the option. I will try, suddenly it will help solve the problem.
Although I prefer the second version of the package build solution that I described)


#35

When I tried to assemble a package, some new errors appeared.
This is due to some sort of change?

snapcraft 
Launching a VM.
'multipass' command not found: this command is necessary to build in this environment.
Install 'multipass' or if already installed, ensure it is on the system PATH, and try again.                                                                                                                                                       

snapcraft cleanbuild      
Usage: snapcraft [OPTIONS] COMMAND [ARGS]...

Error: No such command "cleanbuild".

#36

Multipass is a separate project which Snapcraft 3.0 uses when there is a base keyword specified in the snapcraft.yaml. You can get Multipass as a snap from the beta channel.


#37

Ok, I installed this multipass. But it did not help me. The error is the same.

snapcraft cleanbuild 
Usage: snapcraft [OPTIONS] COMMAND [ARGS]...

Error: No such command "cleanbuild".

#38

Now it looks like a snapcraft.yaml

name: managetime
version: "0.1.0"
summary: timer
description: |
    Application for time management
confinement: strict
architectures: [amd64]
grade: stable
base: core18

apps:
    managetime:
        command: desktop-launch ${SNAP}/bin/projecttimer
        plugs: [home, unity7, x11, opengl, pulseaudio, wayland, network, desktop, desktop-legacy]
        environment:
            DISABLE_WAYLAND: 1
parts:
    managetime:
        plugin: cmake
        configflags:
            - -DCMAKE_BUILD_TYPE=Release
            - -DCMAKE_INSTALL_PREFIX=/usr
            - -DCMAKE_PREFIX_PATH=/media/free/Qt/5.11.0/gcc_64/lib/cmake/
        build-packages:
            - qttools5-dev
            - build-essential
            - qtdeclarative5-dev
            - libqt5svg5-dev
            - qttools5-dev-tools
            - libqt5xmlpatterns5-dev
            - libgles2-mesa-dev
            - qtquickcontrols2-5-dev
        stage-packages:
            - libqt5widgets5
            - libqt5qml5
            - libqt5quick5
            - libqt5quickwidgets5
            - libqt5quickcontrols2-5
            - qml-module-qtquick-controls2
            - qtwayland5
            - libgl1-mesa-dev
            - libgl1-mesa-dri
            - libgl1-mesa-glx
            - libxkbcommon0
        stage:
            - -usr/share/pkgconfig

#39

You have an outdated distribution of Snapcraft. Please ensure you have enable the *-updates pocket of the Ubuntu software sources, refresh the APT local package cache and install all system updates.


#40

I noticed that if specified in snapcraft.yaml base: core18 then this error appears.