【发布时间】:2018-02-02 10:35:43
【问题描述】:
我想打包一个二进制文件以用于 NixOS。为了让它工作,我必须通过 patchelf 更改解释器以链接到 nix 商店内的解释器。到目前为止,一切都很好。二进制文件也有共享库,但如果我使用 patchelf 的 --set-rpath 选项后跟 : concatenated list of library paths:
./result/bin/exe: ./result/bin/exe: no version information available (required by ./result/bin/exe)
./result/bin/exe: ./result/bin/exe: no version information available (required by ./result/bin/exe)
./result/bin/exe: ./result/bin/exe: no version information available (required by ./result/bin/exe)
./result/bin/exe: ./result/bin/exe: no version information available (required by ./result/bin/exe)
./result/bin/exe: ./result/bin/exe: no version information available (required by ./result/bin/exe)
...
./result/bin/exe: relocation error: ./result/bin/exe: symbol , version not defined in file with link time reference
(我删除了一些重复的行)
我有found questions asked on stackoverflow关于第一个错误,这不会造成任何麻烦(链接库不包含版本信息,而可执行文件定义了它想要的版本),虽然我觉得奇怪的是图书馆不见了。问题是下一行,我发现similar error messages 说也许不同版本的 gcc 可以解决问题,但同样缺少库名称。我使用的命令是patchelf --interpreter "$(cat $NIX_CC/nix-support/dynamic-linker)" --set-rpath /nix/store/qt-4.8.7/lib:/nix/store/zlib-1.2.11/lib:/nix/store/gcc-6.4.0-lib/lib:/nix/store/libSM-1.2.2/lib:/nix/store/libICE-1.0.9/lib:/nix/store/libX11-1.6.5/lib:/nix/store/libXext-1.3.3/lib:/nix/store/libXt-1.1.5/lib:/nix/store/mesa-17.1.6/lib exe(删除了长哈希)。
奇怪的是,我可以通过创建一个包装器来运行程序,该包装器将 LD_LIBRARY_PATH 设置为我尝试对 patchelf 所做的完全相同的事情(我仍然需要更改解释器,但这不会导致问题。),但是这不是我想要的解决方案。接下来我应该怎么做?
【问题讨论】: