2016-06-02 9 views
0

Ich mache einen Paket-Manager, und möchte sicherstellen, dass die Pakete die richtige abhängige Bibliothek verwenden, indem Sie rpath Option zum Zeitpunkt der Kompilierung. Aber es überrascht mich in OS X (10.11), hier ist das Problem:Dylib von Rpath festgelegt ist nicht in OS X geladen

$ otool -L /opt/starman/software/gcc/6.1.0/83894f21d07366be296600ec031ae4f6241381d9/libexec/gcc/x86_64-apple-darwin15.5.0/6.1.0/f951 
/opt/starman/software/gcc/6.1.0/83894f21d07366be296600ec031ae4f6241381d9/libexec/gcc/x86_64-apple-darwin15.5.0/6.1.0/f951: 
    /usr/lib/libiconv.2.dylib (compatibility version 7.0.0, current version 7.0.0) 
    /opt/starman/software/isl/0.17.1/104994def2b7fb2dae7950b42205eb718a46ee0c/lib/libisl.15.dylib (compatibility version 18.0.0, current version 18.1.0) 
    /opt/starman/software/mpc/1.0.3/6058925218009b8ab17e07333dc54de334134f6e/lib/libmpc.3.dylib (compatibility version 4.0.0, current version 4.0.0) 
    /opt/starman/software/mpfr/3.1.4/f142dfcda3b56650a8c9cfe2fdd09ffdf7283a00/lib/libmpfr.4.dylib (compatibility version 6.0.0, current version 6.4.0) 
    /opt/starman/software/gmp/6.1.0/0ec8ef118d09cb33f83559685d006f56a74f865c/lib/libgmp.10.dylib (compatibility version 14.0.0, current version 14.0.0) 
    /usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1226.10.1) 

siehe gmp Version 14.0.0 ist.

$ /opt/starman/software/gcc/6.1.0/83894f21d07366be296600ec031ae4f6241381d9/libexec/gcc/x86_64-apple-darwin15.5.0/6.1.0/f951 
dyld: Library not loaded: /opt/starman/software/gmp/6.1.0/0ec8ef118d09cb33f83559685d006f56a74f865c/lib/libgmp.10.dylib 
    Referenced from: /opt/starman/software/gcc/6.1.0/83894f21d07366be296600ec031ae4f6241381d9/libexec/gcc/x86_64-apple-darwin15.5.0/6.1.0/f951 
    Reason: Incompatible library version: f951 requires version 14.0.0 or later, but libgmp.10.dylib provides version 13.0.0 
Trace/BPT trap: 5 

Es sagt gmp in dem richtigen Pfad nicht geladen, da seine Version ist 13.0.0, aber es ist 14.0.0! Ich weiß, dass ich eine ältere Version gmp in einem anderen Pfad installiert habe, also nachdem ich seinen lib Pfad von DYLD_LIBRARY_PATH entferne, ist das Problem weg, aber sollte rpath dieses Problem nicht lösen?

Warum dyld druckt den richtigen Pfad von gmp, aber tatsächlich verwendet die falsche alte? Gibt es Tricks in OS X? Danke für die Hilfe!

EDIT 1: Die Version von /opt/starman/software/gmp/6.1.0/0ec8ef118d09cb33f83559685d006f56a74f865c/lib/libgmp.10.dylib als

$ otool -l /opt/starman/software/gmp/6.1.0/0ec8ef118d09cb33f83559685d006f56a74f865c/lib/libgmp.10.dylib 
... 
     cmdsize 120 
     name /opt/starman/software/gmp/6.1.0/0ec8ef118d09cb33f83559685d006f56a74f865c/lib/libgmp.10.dylib (offset 24) 
    time stamp 1 Thu Jan 1 08:00:01 1970 
     current version 14.0.0 
compatibility version 14.0.0 
... 

Und die älteren gmp geprüft wird, ist

$ otool -l /opt/software/gmp/6.0.0a/0/lib/libgmp.10.dylib 
... 
     name @rpath/lib/libgmp.dylib (offset 24) 
    time stamp 1 Thu Jan 1 08:00:01 1970 
     current version 13.0.0 
compatibility version 13.0.0 
... 

EIDT 2

0xced Laut, ich debuggen den Ladevorgang auszuführen, wie (Die vollständige Ausgabe ist here):

$ export DYLD_PRINT_LIBRARIES="1" 
$ /opt/starman/software/gcc/6.1.0/83894f21d07366be296600ec031ae4f6241381d9/libexec/gcc/x86_64-apple-darwin15.5.0/6.1.0/f951 
dyld: loaded: /opt/starman/software/gcc/6.1.0/83894f21d07366be296600ec031ae4f6241381d9/libexec/gcc/x86_64-apple-darwin15.5.0/6.1.0/f951 
dyld: loaded: /usr/lib/libiconv.2.dylib 
dyld: loaded: /opt/starman/software/isl/0.17.1/104994def2b7fb2dae7950b42205eb718a46ee0c/lib/libisl.15.dylib 
dyld: loaded: /opt/software/packman.active/lib/libmpc.3.dylib 
dyld: loaded: /opt/software/packman.active/lib/libmpfr.4.dylib 
dyld: loaded: /opt/software/packman.active/lib/libgmp.10.dylib 
dyld: unloaded: /opt/starman/software/gcc/6.1.0/83894f21d07366be296600ec031ae4f6241381d9/libexec/gcc/x86_64-apple-darwin15.5.0/6.1.0/f951 
dyld: unloaded: /opt/starman/software/isl/0.17.1/104994def2b7fb2dae7950b42205eb718a46ee0c/lib/libisl.15.dylib 
dyld: unloaded: /opt/software/packman.active/lib/libmpc.3.dylib 
dyld: unloaded: /opt/software/packman.active/lib/libmpfr.4.dylib 
dyld: unloaded: /opt/software/packman.active/lib/libgmp.10.dylib 
dyld: Library not loaded: /opt/starman/software/gmp/6.1.0/0ec8ef118d09cb33f83559685d006f56a74f865c/lib/libgmp.10.dylib 
    Referenced from: /opt/starman/software/gcc/6.1.0/83894f21d07366be296600ec031ae4f6241381d9/libexec/gcc/x86_64-apple-darwin15.5.0/6.1.0/f951 
    Reason: Incompatible library version: f951 requires version 14.0.0 or later, but libgmp.10.dylib provides version 13.0.0 
Trace/BPT trap: 5 
+0

Was hat rpath mit der Frage zu tun? Sind Sie sicher, dass die Version der 'gmp' Bibliothek 14 und nicht 13 ist? – Droppy

+0

Da der 'gmp'-Bibliothekspfad in' f951' fest codiert ist, und ich denke, das ist der Effekt von 'rpath'. Die Versionen der beiden 'gmp' auf meinem Computer sind oben mit' otool -l' dargestellt. –

Antwort

0

Ich verstehe nicht, warum die f951 binären /opt/software/gmp/6.0.0a/0/lib/libgmp.10.dylib (Version 13) statt /opt/starman/software/gmp/6.1.0/0ec8ef118d09cb33f83559685d006f56a74f865c/lib/libgmp.10.dylib (Version 14) geladen werden würde, die mit angegeben ein absoluter Pfad und kein relativer @rpath.

Vielleicht wird es indirekt über eine andere Bibliothek, z. libisl.15.dylib, libmpc.3.dylib oder libmpfr.4.dylib, die einen @ rpath-Verweis auf libgmp.10.dylib haben könnten?

dieses Problem zu diagnostizieren, empfehle ich Ihnen das Hauptprogramm wie folgt auszuführen:

$ DYLD_PRINT_RPATHS=YES /opt/starman/software/gcc/6.1.0/83894f21d07366be296600ec031ae4f6241381d9/libexec/gcc/x86_64-apple-darwin15.5.0/6.1.0/f951 

Dadurch werden alle rpath Erweiterungen (beide Erfolg und Misserfolg) gedruckt und wird die Antwort auf Ihre Frage geben Ihnen wahrscheinlich.

+0

Danke für Hilfe! Ich habe diese Dylibs überprüft und sie haben alle das richtige 'gmp' geladen. Ich führe 'f951' auch mit' DYLD_PRINT_RPATHS = YES', aber es werden keine weiteren Informationen gedruckt. –

+0

Ich exportiere 'DYLD_PRINT_LIBRARIES' zu 1 mit Bezug auf' https: // gist.github.com/wycats/1627976', und es wird gedruckt. Die vollständige Ausgabe ist [hier] (https://gist.github.com/dongli/c0b8153573db0332ef519c74341cd264) –

+0

Funktioniert es, wenn Sie "/ opt/software/packman.active/lib" aus Ihrer Umgebungsvariable 'DYLD_LIBRARY_PATH' entfernen? – 0xced