xmake icon indicating copy to clipboard operation
xmake copied to clipboard

The pack plugin does not package the qt dynamic library files that qt's application depends

Open yinntian opened this issue 1 year ago • 5 comments

Xmake 版本

xmake v2.8.6+HEAD.211710b

操作系统版本和架构

Linux 6.5.0-14-generic #14-Ubuntu SMP PREEMPT_DYNAMIC Tue Nov 14 14:59:49 UTC 2023 x86_64 x86_64 x86_64 GNU/Linux

描述问题

使用 pack 生成免安装格式的 zip 包,但里面只有 target 定义的二进制应用程序,依赖的 qt 动态库都没有进行打包到 zip 内。 我在最小实现的示例工程里定义了一个简单的动态库 target ,能够正确的被 pack 插件打包到 zip 包内,但 qt 的运行环境没有进行打包。最小的示例工程(hello.zip)我附在下方,使用的话需要修改 xmake.lua 内的 qt 的路径。 hello.zip

期待的结果

动态库和二进制程序一起打包到 zip 压缩包内

工程配置

add_rules("mode.debug", "mode.release")

set_config("qt", "~/opt/Qt")

target("simpleso")
    set_kind("shared")
    add_includedirs("lib/simpleso", {public = true})
    add_files("lib/simpleso/*.cpp")

target("hello")
    add_rules("qt.widgetapp")
    add_deps("simpleso")

    add_headerfiles("src/*.h")
    add_files("src/*.cpp")
    add_files("src/mainwindow.ui")
    -- add files with Q_OBJECT meta (only for qt.moc)
    add_files("src/mainwindow.h")

includes("@builtin/xpack")
xpack("hello")
    set_formats("zip")
    set_libdir("lib")
    add_targets("hello")

附加信息和错误日志

xmake b -vD

xmake b -vD
checking for platform ... linux
checking for architecture ... x86_64
checking for gcc ... /usr/bin/gcc
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checkinfo: cannot runv(zig version), No such file or directory
checking for zig ... no
checking for Qt SDK directory ... /home/yt/opt/Qt/6.6.1/gcc_64
checking for Qt SDK version ... 6.6.1
[ 18%]: compiling.qt.ui src/mainwindow.ui
/home/yt/opt/Qt/6.6.1/gcc_64/libexec/uic src/mainwindow.ui -o build/.gens/hello/linux/x86_64/release/rules/qt/ui/ui_mainwindow.h
checking for gcc ... /usr/bin/gcc
checking for the c++ compiler (cxx) ... gcc
checking for /usr/bin/gcc ... ok
checking for flags (-fPIC) ... ok
> gcc "-fPIC" "-m64"
checking for flags (-O3) ... ok
> gcc "-O3" "-m64"
checking for flags (-DNDEBUG) ... ok
> gcc "-DNDEBUG" "-m64"
[ 18%]: cache compiling.release lib/simpleso/simpleso.cpp
/usr/bin/gcc -c -m64 -fPIC -O3 -Ilib/simpleso -DNDEBUG -o build/.objs/simpleso/linux/x86_64/release/lib/simpleso/simpleso.cpp.o lib/simpleso/simpleso.cpp
checking for flags (-MMD -MF) ... ok
> gcc "-MMD" "-MF" "/dev/null" "-m64"
checking for flags (-fdiagnostics-color=always) ... ok
> gcc "-fdiagnostics-color=always" "-m64"
checking for g++ ... /usr/bin/g++
checking for the shared library linker (sh) ... g++
checking for /usr/bin/g++ ... ok
checking for flags (-fPIC) ... ok
> g++ "-fPIC" "-shared" "-m64" "-m64"
[ 36%]: linking.release libsimpleso.so
/usr/bin/g++ -o build/linux/x86_64/release/libsimpleso.so build/.objs/simpleso/linux/x86_64/release/lib/simpleso/simpleso.cpp.o -shared -m64 -fPIC -s
checking for flags (-fvisibility-inlines-hidden) ... ok
> gcc "-fvisibility-inlines-hidden" "-m64"
checking for flags (-fPIC) ... ok
> gcc "-fPIC" "-m64"
[ 54%]: compiling.qt.moc src/mainwindow.h
/home/yt/opt/Qt/6.6.1/gcc_64/libexec/moc -DQT_NO_DEBUG -DQT_DEPRECATED_WARNINGS -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_CORE_LIB -I/home/yt/workspace/hello/build/.gens/hello/linux/x86_64/release/rules/qt/ui -Ilib/simpleso -I/home/yt/opt/Qt/6.6.1/gcc_64/include/QtGui -I/home/yt/opt/Qt/6.6.1/gcc_64/include/QtGui/6.6.1 -I/home/yt/opt/Qt/6.6.1/gcc_64/include/QtGui/6.6.1/QtGui -I/home/yt/opt/Qt/6.6.1/gcc_64/include/QtWidgets -I/home/yt/opt/Qt/6.6.1/gcc_64/include/QtWidgets/6.6.1 -I/home/yt/opt/Qt/6.6.1/gcc_64/include/QtWidgets/6.6.1/QtWidgets -I/home/yt/opt/Qt/6.6.1/gcc_64/include/QtCore -I/home/yt/opt/Qt/6.6.1/gcc_64/include/QtCore/6.6.1 -I/home/yt/opt/Qt/6.6.1/gcc_64/include/QtCore/6.6.1/QtCore -I/home/yt/opt/Qt/6.6.1/gcc_64/include -I/home/yt/opt/Qt/6.6.1/gcc_64/mkspecs/linux-g++ src/mainwindow.h -o build/.gens/hello/linux/x86_64/release/src/moc_mainwindow.cpp
/usr/bin/gcc -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -I/home/yt/workspace/hello/build/.gens/hello/linux/x86_64/release/rules/qt/ui -Ilib/simpleso -DQT_NO_DEBUG -DQT_DEPRECATED_WARNINGS -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_CORE_LIB -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtGui -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtGui/6.6.1 -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtGui/6.6.1/QtGui -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtWidgets -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtWidgets/6.6.1 -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtWidgets/6.6.1/QtWidgets -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtCore -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtCore/6.6.1 -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtCore/6.6.1/QtCore -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include -isystem /home/yt/opt/Qt/6.6.1/gcc_64/mkspecs/linux-g++ -DNDEBUG -fPIC -o build/.objs/hello/linux/x86_64/release/gens/src/moc_mainwindow.cpp.o build/.gens/hello/linux/x86_64/release/src/moc_mainwindow.cpp
[ 63%]: cache compiling.release src/mainwindow.cpp
/usr/bin/gcc -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -I/home/yt/workspace/hello/build/.gens/hello/linux/x86_64/release/rules/qt/ui -Ilib/simpleso -DQT_NO_DEBUG -DQT_DEPRECATED_WARNINGS -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_CORE_LIB -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtGui -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtGui/6.6.1 -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtGui/6.6.1/QtGui -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtWidgets -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtWidgets/6.6.1 -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtWidgets/6.6.1/QtWidgets -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtCore -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtCore/6.6.1 -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtCore/6.6.1/QtCore -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include -isystem /home/yt/opt/Qt/6.6.1/gcc_64/mkspecs/linux-g++ -DNDEBUG -fPIC -o build/.objs/hello/linux/x86_64/release/src/mainwindow.cpp.o src/mainwindow.cpp
[ 63%]: cache compiling.release src/main.cpp
/usr/bin/gcc -c -m64 -fvisibility=hidden -fvisibility-inlines-hidden -O3 -std=c++17 -I/home/yt/workspace/hello/build/.gens/hello/linux/x86_64/release/rules/qt/ui -Ilib/simpleso -DQT_NO_DEBUG -DQT_DEPRECATED_WARNINGS -DQT_GUI_LIB -DQT_WIDGETS_LIB -DQT_CORE_LIB -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtGui -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtGui/6.6.1 -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtGui/6.6.1/QtGui -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtWidgets -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtWidgets/6.6.1 -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtWidgets/6.6.1/QtWidgets -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtCore -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtCore/6.6.1 -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include/QtCore/6.6.1/QtCore -isystem /home/yt/opt/Qt/6.6.1/gcc_64/include -isystem /home/yt/opt/Qt/6.6.1/gcc_64/mkspecs/linux-g++ -DNDEBUG -fPIC -o build/.objs/hello/linux/x86_64/release/src/main.cpp.o src/main.cpp
checking for g++ ... /usr/bin/g++
checking for the linker (ld) ... g++
checking for flags (-fPIC) ... ok
> g++ "-fPIC" "-m64" "-m64"
checking for flags (-Wl,-rpath=@loader_path) ... ok
> g++ "-Wl,-rpath=@loader_path" "-m64" "-m64"
checking for flags (-Wl,-rpath=/home/yt/opt/Qt/6.6.1/gcc_64/lib) ... ok
> g++ "-Wl,-rpath=/home/yt/opt/Qt/6.6.1/gcc_64/lib" "-m64" "-m64"
[ 81%]: linking.release hello
/usr/bin/g++ -o build/linux/x86_64/release/hello build/.objs/hello/linux/x86_64/release/src/mainwindow.cpp.o build/.objs/hello/linux/x86_64/release/src/main.cpp.o build/.objs/hello/linux/x86_64/release/gens/src/moc_mainwindow.cpp.o -m64 -L/home/yt/opt/Qt/6.6.1/gcc_64/lib -Lbuild/linux/x86_64/release -Wl,-rpath=$ORIGIN -Wl,-rpath=/home/yt/opt/Qt/6.6.1/gcc_64/lib -s -lsimpleso -lQt6Gui -lQt6Widgets -lQt6Core

build cache stats:
cache directory: build/.build_cache
cache hit rate: 0%
cache hit: 0
cache miss: 3
new cached files: 3
remote cache hit: 0
remote new cached files: 0
preprocess failed: 0
compile fallback count: 0

[100%]: build ok, spent 3.668s

xmake pack -vD -o bin

xmake pack -vD -o bin

build cache stats:
cache directory: build/.build_cache
cache hit rate: 0%
cache hit: 0
cache miss: 0
new cached files: 0
remote cache hit: 0
remote new cached files: 0
preprocess failed: 0
compile fallback count: 0

packing bin/hello.zip .. 
/usr/bin/zip /home/yt/workspace/hello/bin/hello.zip -9 -r -@
updating: bin/hello (deflated 75%)
updating: bin/libsimpleso.so (deflated 85%)
pack ok

yinntian avatar Jan 31 '24 07:01 yinntian

qt 是还没支持,之前一直没时间搞,你可以先自己通过 add_installfiles 在 xpack() 里面配下就行了。

waruqi avatar Jan 31 '24 08:01 waruqi

Bot detected the issue body's language is not English, translate it automatically.


qt is not supported yet, and I haven’t had time to do it before.

Issues-translate-bot avatar Jan 31 '24 08:01 Issues-translate-bot

还没支持啊... 那我调什么 api 可以得到所有 link 的动态库,我虽然知道动态库的路径在哪,但换到别人的电脑就不行了。

yinntian avatar Jan 31 '24 08:01 yinntian

Bot detected the issue body's language is not English, translate it automatically.


It's not supported yet... Then what API can I adjust to get all the dynamic libraries of links? Although I know where the path of the dynamic library is, it won't work if I switch to someone else's computer.

Issues-translate-bot avatar Jan 31 '24 08:01 Issues-translate-bot

before_package 里面 os.files 自己动态扫下

waruqi avatar Jan 31 '24 09:01 waruqi