2017-08-24 446 views
0

我想打包一個二進制文件以便與NixOS一起使用。爲了工作,我必須通過patchelf將解釋器更改爲鏈接到nix商店內的解釋器。到現在爲止還挺好。二進制也有共享庫,但我得到一個奇怪的錯誤消息,如果我使用其次patchelf的--set-rpath的選項:庫路徑拼接列表:patchelf後,Linux可執行文件無法運行

./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完全相同的事情(我仍然需要更改解釋器,但這不會導致問題)但這不是我想要的解決方案..接下來我該怎麼做?

回答

0

接下來我該怎麼做?

您的patchelf損壞二進制文件。

你必須弄清楚腐敗是什麼,並修復patchelf沒有該錯誤。

或者,如果您可以重新鏈接二進制文件,您可以簡單地使用--dynamic-linker=...提供正確的解釋器並根據您的喜好使用--rpath=...連接器參數設置RPATH