erszcz / erlang-rust-nif

An example Erlang NIF implemented in Rust
80 stars 4 forks source link

make is unsuccessful on MacOS #3

Open abhipras opened 9 years ago

abhipras commented 9 years ago

When I run make, I get the following error

                                             ^~~~~~~~~~~~~~~~~~~
error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "-o" "/Users/macpro/erlang_projects/erlang-rust-nif/rust_src/target/debug/liber-75adb9f2bb77bd1a.dylib" "/Users/macpro/erlang_projects/erlang-rust-nif/rust_src/target/debug/er-75adb9f2bb77bd1a.o" "-Wl,-force_load,/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libmorestack.a" "/Users/macpro/erlang_projects/erlang-rust-nif/rust_src/target/debug/er-75adb9f2bb77bd1a.metadata.o" "-Wl,-dead_strip" "-nodefaultlibs" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libstd-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcollections-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libunicode-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/librand-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liballoc-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/liblibc-4e7c5e5c.rlib" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib/libcore-4e7c5e5c.rlib" "-L" "/Users/macpro/erlang_projects/erlang-rust-nif/rust_src/target/debug" "-L" "/Users/macpro/erlang_projects/erlang-rust-nif/rust_src/target/debug/deps" "-L" "/usr/local/lib/rustlib/x86_64-apple-darwin/lib" "-L" "/Users/macpro/erlang_projects/erlang-rust-nif/rust_src/.rust/lib/x86_64-apple-darwin" "-L" "/Users/macpro/erlang_projects/erlang-rust-nif/rust_src/lib/x86_64-apple-darwin" "-lSystem" "-lpthread" "-lc" "-lm" "-dynamiclib" "-Wl,-dylib" "-lcompiler-rt"
note: ld: warning: directory not found for option '-L/Users/macpro/erlang_projects/erlang-rust-nif/rust_src/.rust/lib/x86_64-apple-darwin'
ld: warning: directory not found for option '-L/Users/macpro/erlang_projects/erlang-rust-nif/rust_src/lib/x86_64-apple-darwin'
Undefined symbols for architecture x86_64:
  "_enif_make_badarg", referenced from:
      native_add::__rust_abi in er-75adb9f2bb77bd1a.o
  "_enif_get_int", referenced from:
      native_add::__rust_abi in er-75adb9f2bb77bd1a.o
  "_enif_make_int", referenced from:
      native_add::__rust_abi in er-75adb9f2bb77bd1a.o
ld: symbol(s) not found for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)

error: aborting due to previous error
Could not compile `er`.
erszcz commented 9 years ago

Hi! I'm aware of that, but don't have time to fix it. Please try branch macosx-wip, but don't forget to customize the Makefile:

ERLANG_SRC_DIR ?= ${HOME}/.kerl/builds/17.1/otp_src_17.1
ERLANG_EI_LIB_DIR ?= ${HOME}/apps/erlang/17.1/lib/erl_interface-3.7.17/lib
erszcz commented 9 years ago

This problem really boils down to adding -flat_namespace -undefined suppress to the compiler command line. If you know how to convince Cargo to do that, it should build just fine.

ChinaXing commented 9 years ago

_-flatnamespace -undefined suppress it works