Cannot compile libunicorn-sys on osx


#1

Hi there,

I tried to add unicorn bindings to my project by adding unicorn = "0.4.1" as a dependency. Running cargo afterwards results in the following error:

$ cargo run --verbose
       Fresh libc v0.2.20
       Fresh bitflags v0.6.0
       Fresh gcc v0.3.41
       Fresh byteorder v1.0.0
   Compiling libunicorn-sys v0.4.0
     Running `rustc /Users/$username/.cargo/registry/src/github.com-1ecc6299db9ec823/libunicorn-sys-0.4.0/lib.rs --crate-name libunicorn_sys \
--crate-type lib -g -C metadata=271778d4aa553e9c -C extra-filename=-271778d4aa553e9c --out-dir \
/Users/$username/dev/$project/target/debug/deps --emit=dep-info,link -L \
dependency=/Users/$username/dev/$project/target/debug/deps --extern \
libc=/Users/$username/dev/$project/target/debug/deps/liblibc-29ef97a68464c2b7.rlib --extern \
bitflags=/Users/$username/dev/$project/target/debug/deps/libbitflags-b8c7fb7df9b2bc2e.rlib --cap-lints allow -L \
native=/Users/$username/dev/$project/target/debug/build/libunicorn-sys-fe33b86568c508cb/out -l static=unicorn`

error: failed to add native library /Users/$user/dev/$project/target/debug/build/libunicorn-sys-fe33b86568c508cb/out/libunicorn.a: failed to open archive

error: Could not compile `libunicorn-sys`.

Caused by:
  process didn't exit successfully: `rustc /Users/$user/.cargo/registry/src/github.com-1ecc6299db9ec823/libunicorn-sys-0.4.0/lib.rs --crate-name libunicorn_sys --crate-type lib -g -C metadata=271778d4aa553e9c -C extra-filename=-271778d4aa553e9c --out-dir /Users/$user/dev/$project/target/debug/deps --emit=dep-info,link -L dependency=/Users/$user/dev/$project/target/debug/deps --extern libc=/Users/$user/dev/$project/target/debug/deps/liblibc-29ef97a68464c2b7.rlib --extern bitflags=/Users/$user/dev/$project/target/debug/deps/libbitflags-b8c7fb7df9b2bc2e.rlib --cap-lints allow -L native=/Users/$user/dev/$project/target/debug/build/libunicorn-sys-fe33b86568c508cb/out -l static=unicorn` (exit code: 101)

(I added the ""s to make it more readable)

now file reveals the following:

$ file /Users/$username/dev/$project/target/debug/build/libunicorn-sys-fe33b86568c508cb/out/libunicorn.a
/Users/$username/dev/$project/target/debug/build/libunicorn-sys-fe33b86568c508cb/out/libunicorn.a: Mach-O universal binary with 2 architectures: [x86_64: current ar archive random library] [i386]
/Users/$username/dev/$project/target/debug/build/libunicorn-sys-fe33b86568c508cb/out/libunicorn.a (for architecture x86_64):	current ar archive random library
/Users/$username/dev/$project/target/debug/build/libunicorn-sys-fe33b86568c508cb/out/libunicorn.a (for architecture i386):	current ar archive random library


I assume the error is from here but unfortunately running rustc with RUST_BACKTRACE=1 does not reveal more information.

$ rustc --version
rustc 1.14.0
$ cargo --version
cargo 0.15.0-dev (298a012 2016-12-20)

Any idea what is required to make it compile?