我想为NixOS打包一个二进制文件。为了使其工作,我必须通过patchelf更改解释器,以链接到nix store中的解释器。到目前为止都很好。该二进制文件还具有共享库,但如果我使用patchelf的--set-rpath选项,后跟由冒号分隔的库路径列表,则会收到奇怪的错误消息。
./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
(我删除了一些重复的行)
我在stackoverflow上发现了一些关于第一个错误的问题,这应该不会造成任何麻烦(链接库不包含版本信息,而可执行文件定义了它想要的版本),但我发现奇怪的是库的名称缺失了。问题出在下一行,我找到了类似的错误信息,说也许使用不同版本的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
(已删除长哈希值)。