简体   繁体   中英

Building a debian package using non-debian managed libraries

I'm trying to build a Debian package which uses the Qt5 library. I have Qt installed in /opt and the libraries can be found at /opt/Qt/5.15.0/gcc_64/lib .

The binaries I'm trying to put in a Debian package are written in C++, and I'm using CMake to as buildsystem.

My debian/rules file contain the following:

#!/usr/bin/make -f

DH_VERBOSE = 1

%:
        dh $@ --builddirectory=build

override_dh_auto_configure:
        dh_auto_configure -- -DQt5_DIR=/opt/Qt/5.15.0/gcc_64/lib/cmake/Qt5

override_dh_shlibdeps:
        dh_shlibdeps -l /opt/Qt/5.15.0/gcc_64/lib/ -- --ignore-missing-info

The override_dh_shlibdeps is my attempt to have it linked to the correct libraries, but it doesn't.

I build the Debian package using the following command: debuild -us -uc

Using this rules file I get the following result with ldd:

        linux-vdso.so.1 (0x00007ffff4ff5000)
        libgrpc++.so.1 => /lib/x86_64-linux-gnu/libgrpc++.so.1 (0x00007f35100c1000)
        libprotobuf.so.17 => /lib/x86_64-linux-gnu/libprotobuf.so.17 (0x00007f350fdc9000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f350fda6000)
        libQt5Qml.so.5 => not found
        libQt5Core.so.5 => /lib/x86_64-linux-gnu/libQt5Core.so.5 (0x00007f350f85d000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f350f67c000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f350f65f000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f350f46d000)
        libgrpc.so.6 => /lib/x86_64-linux-gnu/libgrpc.so.6 (0x00007f350f319000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f351015d000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f350f2fd000)
        libicui18n.so.66 => /lib/x86_64-linux-gnu/libicui18n.so.66 (0x00007f350effe000)
        libicuuc.so.66 => /lib/x86_64-linux-gnu/libicuuc.so.66 (0x00007f350ee18000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f350ee10000)
        libpcre2-16.so.0 => /lib/x86_64-linux-gnu/libpcre2-16.so.0 (0x00007f350ed8d000)
        libdouble-conversion.so.3 => /lib/x86_64-linux-gnu/libdouble-conversion.so.3 (0x00007f350ed77000)
        libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f350ec4e000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f350eaff000)
        libssl.so.1.1 => /lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007f350ea6c000)
        libcrypto.so.1.1 => /lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007f350e794000)
        libcares.so.2 => /lib/x86_64-linux-gnu/libcares.so.2 (0x00007f350e780000)
        libicudata.so.66 => /lib/x86_64-linux-gnu/libicudata.so.66 (0x00007f350ccbf000)
        libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f350cc4c000)

It can't find the libQt5Qml, as I do not have it installed using the package manager. This did not throw up an error as I have added --ignore-missing-info to it.

So is there a way to have it linked to the /opt/ directory one and not the one installed via the package manager?

The way it should be, if interested:

        linux-vdso.so.1 (0x00007ffd3a907000)
        libgrpc++.so.1 => /lib/x86_64-linux-gnu/libgrpc++.so.1 (0x00007f3cdc735000)
        libprotobuf.so.17 => /lib/x86_64-linux-gnu/libprotobuf.so.17 (0x00007f3cdc43d000)
        libpthread.so.0 => /lib/x86_64-linux-gnu/libpthread.so.0 (0x00007f3cdc41a000)
        libQt5Qml.so.5 => /opt/Qt/5.15.0/gcc_64/lib/libQt5Qml.so.5 (0x00007f3cdbd9d000)
        libQt5Core.so.5 => /opt/Qt/5.15.0/gcc_64/lib/libQt5Core.so.5 (0x00007f3cdb5aa000)
        libstdc++.so.6 => /lib/x86_64-linux-gnu/libstdc++.so.6 (0x00007f3cdb3c9000)
        libgcc_s.so.1 => /lib/x86_64-linux-gnu/libgcc_s.so.1 (0x00007f3cdb3ac000)
        libc.so.6 => /lib/x86_64-linux-gnu/libc.so.6 (0x00007f3cdb1ba000)
        libgrpc.so.6 => /lib/x86_64-linux-gnu/libgrpc.so.6 (0x00007f3cdb066000)
        /lib64/ld-linux-x86-64.so.2 (0x00007f3cdc7d1000)
        libz.so.1 => /lib/x86_64-linux-gnu/libz.so.1 (0x00007f3cdb04a000)
        libQt5Network.so.5 => /opt/Qt/5.15.0/gcc_64/lib/libQt5Network.so.5 (0x00007f3cdac9c000)
        librt.so.1 => /lib/x86_64-linux-gnu/librt.so.1 (0x00007f3cdac91000)
        libm.so.6 => /lib/x86_64-linux-gnu/libm.so.6 (0x00007f3cdab40000)
        libicui18n.so.56 => /opt/Qt/5.15.0/gcc_64/lib/libicui18n.so.56 (0x00007f3cda6a7000)
        libicuuc.so.56 => /opt/Qt/5.15.0/gcc_64/lib/libicuuc.so.56 (0x00007f3cda2ef000)
        libicudata.so.56 => /opt/Qt/5.15.0/gcc_64/lib/libicudata.so.56 (0x00007f3cd890c000)
        libdl.so.2 => /lib/x86_64-linux-gnu/libdl.so.2 (0x00007f3cd8906000)
        libgthread-2.0.so.0 => /lib/x86_64-linux-gnu/libgthread-2.0.so.0 (0x00007f3cd8901000)
        libglib-2.0.so.0 => /lib/x86_64-linux-gnu/libglib-2.0.so.0 (0x00007f3cd87d6000)
        libssl.so.1.1 => /lib/x86_64-linux-gnu/libssl.so.1.1 (0x00007f3cd8743000)
        libcrypto.so.1.1 => /lib/x86_64-linux-gnu/libcrypto.so.1.1 (0x00007f3cd846d000)
        libcares.so.2 => /lib/x86_64-linux-gnu/libcares.so.2 (0x00007f3cd8459000)
        libgssapi_krb5.so.2 => /lib/x86_64-linux-gnu/libgssapi_krb5.so.2 (0x00007f3cd840c000)
        libpcre.so.3 => /lib/x86_64-linux-gnu/libpcre.so.3 (0x00007f3cd8397000)
        libkrb5.so.3 => /lib/x86_64-linux-gnu/libkrb5.so.3 (0x00007f3cd82ba000)
        libk5crypto.so.3 => /lib/x86_64-linux-gnu/libk5crypto.so.3 (0x00007f3cd8289000)
        libcom_err.so.2 => /lib/x86_64-linux-gnu/libcom_err.so.2 (0x00007f3cd8282000)
        libkrb5support.so.0 => /lib/x86_64-linux-gnu/libkrb5support.so.0 (0x00007f3cd8273000)
        libkeyutils.so.1 => /lib/x86_64-linux-gnu/libkeyutils.so.1 (0x00007f3cd826a000)
        libresolv.so.2 => /lib/x86_64-linux-gnu/libresolv.so.2 (0x00007f3cd824e000)

This is what I get when building it, in my build folder.

I figured out how to fix it. The main problem was in my CMake file.

In my CMake I just did find_package(Qt5 COMPONENTS Core Quick REQUIRED) . But CMake install does not know where the libraries can be found to link with.

So I had to set CMAKE_INSTALL_RPATH variable. In my case I had to set it to /opt/Qt/5.15.0/gcc_64/lib/ . (This can be done via command line using -D )

To automate this process I based the variable around the Qt5_DIR variable which is needed for CMake to find all the Qt modules.

get_filename_component(Qt5_CMAKE_DIR ${Qt5_DIR} DIRECTORY)
get_filename_component(Qt5_LIBRARY_DIR ${Qt5_CMAKE_DIR} DIRECTORY)
list(APPEND CMAKE_INSTALL_RPATH ${Qt5_LIBRARY_DIR})

As long as CMake can find Qt, everything gets properly set by default.

For building the Debian package it is important to have the following in your rules:

override_dh_shlibdeps:
        dh_shlibdeps -- --ignore-missing-info

As the Qt is not installed with the package manager.

When installing the Debian package you will also have to use --force-all because the dependency is not shipped with the package, and it will fail otherwise.

Lastly: I do not recommend using this way to build packages as this is not maintainable if you want to share/distribute your package to others.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM