[英]Building a debian package using non-debian managed libraries
I'm trying to build a Debian package which uses the Qt5 library.我正在尝试构建一个使用 Qt5 库的 Debian package 库。 I have Qt installed in /opt and the libraries can be found at
/opt/Qt/5.15.0/gcc_64/lib
.我在 /opt 中安装了 Qt ,可以在
/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. 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:我的 debian/rules 文件包含以下内容:
#!/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. override_dh_shlibdeps 是我尝试将它链接到正确的库,但它没有。
I build the Debian package using the following command: debuild -us -uc
我使用以下命令构建 Debian package:
debuild -us -uc
Using this rules file I get the following result with ldd:使用此规则文件,我通过 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.它找不到 libQt5Qml,因为我没有使用 package 管理器安装它。 This did not throw up an error as I have added
--ignore-missing-info
to it.这并没有引发错误,因为我已向其中添加了
--ignore-missing-info
。
So is there a way to have it linked to the /opt/ directory one and not the one installed via the package manager?那么有没有办法让它链接到 /opt/ 目录一个而不是通过 package 管理器安装的那个?
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.
主要问题出在我的 CMake 文件中。
In my CMake I just did find_package(Qt5 COMPONENTS Core Quick REQUIRED)
.在我的 CMake 中,我刚刚做了
find_package(Qt5 COMPONENTS Core Quick REQUIRED)
。 But CMake install does not know where the libraries can be found to link with.但是 CMake install 不知道在哪里可以找到要链接的库。
So I had to set CMAKE_INSTALL_RPATH
variable.所以我不得不设置
CMAKE_INSTALL_RPATH
变量。 In my case I had to set it to /opt/Qt/5.15.0/gcc_64/lib/
.就我而言,我必须将其设置为
/opt/Qt/5.15.0/gcc_64/lib/
。 (This can be done via command line using -D
) (这可以通过命令行使用
-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.为了自动化这个过程,我基于
Qt5_DIR
变量的变量,这是 CMake 查找所有 Qt 模块所需的。
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.只要 CMake 可以找到 ZE8801102A40AD89DDCFCFDCAEBF008D25Z,默认情况下一切都会正确设置。
For building the Debian package it is important to have the following in your rules:为了构建 Debian package,在您的规则中包含以下内容很重要:
override_dh_shlibdeps:
dh_shlibdeps -- --ignore-missing-info
As the Qt is not installed with the package manager.由于 Qt 没有与 package 管理器一起安装。
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.安装 Debian package 时,您还必须使用
--force-all
因为依赖项未随 package 一起提供,否则它将失败。
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.最后:我不建议使用这种方式来构建软件包,因为如果您想将 package 共享/分发给其他人,这是不可维护的。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.