2015-08-12 7 views
5

Ich versuche, Racer zu ändern, um eine gemeinsam genutzte Bibliothek anstelle einer rlib auszugeben.Auswählen einer freigegebenen oder statischen Bibliothek mit Cargo

Um dies zu tun, fügte ich crate-type = ["dylib"] in die [lib] Abschnitt des Cargo-Manifest, dann lief cargo build --lib. Das funktionierte großartig, und libracer.so wurde ausgegeben.

Leider konnte ich jetzt nicht die Racer-Binärdatei erstellen, die von einer statischen Version der Bibliothek abhängt. Laufen cargo build klagt:

Compiling racer v1.0.0 (file:///home/georgev/dotfiles/vim/bundle/racer) 
error: cannot satisfy dependencies so `std` only shows up once 
help: having upstream crates all available in one format will likely make this go away 
error: cannot satisfy dependencies so `core` only shows up once 
help: having upstream crates all available in one format will likely make this go away 
error: cannot satisfy dependencies so `collections` only shows up once 
help: having upstream crates all available in one format will likely make this go away 
error: cannot satisfy dependencies so `rustc_unicode` only shows up once 
help: having upstream crates all available in one format will likely make this go away 
error: cannot satisfy dependencies so `alloc` only shows up once 
help: having upstream crates all available in one format will likely make this go away 
error: cannot satisfy dependencies so `libc` only shows up once 
help: having upstream crates all available in one format will likely make this go away 
error: cannot satisfy dependencies so `rand` only shows up once 
help: having upstream crates all available in one format will likely make this go away 
error: aborting due to 7 previous errors 
Could not compile `racer`. 

ich die crate-type-["dylib", "bin"] geändert, was die Zusammenstellung erlaubt erfolgreich zu sein. cargo build --lib wird jedoch keine gemeinsame Bibliothek mehr ausgeben (nur eine rlib).

Wie kann ich angeben, welche Art von Bibliothek ich erstellen möchte, während diese Bibliothek trotzdem statisch für die Einbindung in eine ausführbare Datei erstellt werden kann?

Antwort

6

bin ist kein gültiger crate-type Wert. Die gültigen Werte sind rlib, lib, staticlib und dylib. Ändern Sie den Kistentyp in

crate-type = ["dylib", "rlib"] 

wird das Verhalten verursachen, das Sie suchen.

Der Grund, dass nur eine rlib mit ["dylib", "bin"] ausgegeben wird, ist, weil es derzeit einen Cargo-Fehler gibt, der ungültige Werte für crate-type verursacht, um nur eine rlib zu erzeugen. Ich habe eine pull request eingereicht, um das Problem zu beheben.

Verwandte Themen