Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile errors on OSX #16

Closed
developerworks opened this issue Jun 7, 2016 · 7 comments
Closed

Compile errors on OSX #16

developerworks opened this issue Jun 7, 2016 · 7 comments

Comments

@developerworks
Copy link

create build directory and clone repos:

mkdir /tmp/rustler_test
cd /tmp/rustler_test 
git clone https://github.com/hansihe/Rustler.git
git clone https://github.com/hansihe/Rustler_Example.git
cd Rustler_Example/native
rustup override add nightly-2016-05-07-x86_64-apple-darwin

build:

cargo build

errors output:

    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling libc v0.2.11
   Compiling easy-plugin v0.3.4
   Compiling lazy_static v0.1.16
   Compiling aster v0.16.0
   Compiling ruster_unsafe v0.4.0
   Compiling rustler v0.8.3 (file:///private/tmp/rustler_test/Rustler)
/private/tmp/rustler_test/Rustler/src/codegen_runtime.rs:8:5: 8:24 warning: use of deprecated item: renamed to `catch_unwind`, #[warn(deprecated)] on by default
/private/tmp/rustler_test/Rustler/src/codegen_runtime.rs:8 use std::panic::recover;
                                                               ^~~~~~~~~~~~~~~~~~~
/private/tmp/rustler_test/Rustler/src/codegen_runtime.rs:23:51: 23:58 warning: use of deprecated item: renamed to `catch_unwind`, #[warn(deprecated)] on by default
/private/tmp/rustler_test/Rustler/src/codegen_runtime.rs:23     let result: ::std::thread::Result<NIF_TERM> = recover(|| {
                                                                                                              ^~~~~~~
   Compiling rustler_codegen v0.8.3 (file:///private/tmp/rustler_test/Rustler/rustler_codegen)
/private/tmp/rustler_test/Rustler/rustler_codegen/src/resource.rs:66:13: 66:20 warning: unused variable: `builder`, #[warn(unused_variables)] on by default
/private/tmp/rustler_test/Rustler/rustler_codegen/src/resource.rs:66         let builder = ::aster::AstBuilder::new().span(span);
                                                                                 ^~~~~~~
/private/tmp/rustler_test/Rustler/rustler_codegen/src/resource.rs:66:13: 66:20 note: in this expansion of easy_plugin! (defined in /private/tmp/rustler_test/Rustler/rustler_codegen/src/lib.rs)
   Compiling native v0.1.0 (file:///private/tmp/rustler_test/Rustler_Example/native)
src/lib.rs:31:26: 31:35 warning: unused variable: `load_info`, #[warn(unused_variables)] on by default
src/lib.rs:31 fn on_load(env: &NifEnv, load_info: NifTerm) -> bool {
                                       ^~~~~~~~~
src/lib.rs:68:46: 68:50 warning: unused variable: `args`, #[warn(unused_variables)] on by default
src/lib.rs:68 fn make_resource_struct<'a>(env: &'a NifEnv, args: &Vec<NifTerm>) -> Result<NifTerm<'a>, NifError> {
                                                           ^~~~
src/lib.rs:80:37: 80:41 warning: unused variable: `args`, #[warn(unused_variables)] on by default
src/lib.rs:80 fn string_test<'a>(env: &'a NifEnv, args: &Vec<NifTerm>) -> Result<NifTerm<'a>, NifError> {
                                                  ^~~~
error: linking with `cc` failed: exit code: 1
note: "cc" "-m64" "-L" "/Users/hezhiqiang/.multirust/toolchains/nightly-2016-05-07-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "/private/tmp/rustler_test/Rustler_Example/native/target/debug/rust_nif.0.o" "-o" "/private/tmp/rustler_test/Rustler_Example/native/target/debug/librust_nif.dylib" "/private/tmp/rustler_test/Rustler_Example/native/target/debug/rust_nif.metadata.o" "-Wl,-dead_strip" "-nodefaultlibs" "-L" "/private/tmp/rustler_test/Rustler_Example/native/target/debug" "-L" "/private/tmp/rustler_test/Rustler_Example/native/target/debug/deps" "-L" "/Users/hezhiqiang/.multirust/toolchains/nightly-2016-05-07-x86_64-apple-darwin/lib/rustlib/x86_64-apple-darwin/lib" "-Wl,-force_load,/var/folders/m3/vn1yyrfx7l36cq6p8msc6wt80000gn/T/rustc.qQqNIUT1sO3i/librustler-73f06792a5236e6b.rlib" "-Wl,-force_load,/var/folders/m3/vn1yyrfx7l36cq6p8msc6wt80000gn/T/rustc.qQqNIUT1sO3i/libruster_unsafe-256b634055e24e72.rlib" "-Wl,-force_load,/var/folders/m3/vn1yyrfx7l36cq6p8msc6wt80000gn/T/rustc.qQqNIUT1sO3i/liblibc-6b483f9a7097e9a4.rlib" "-Wl,-force_load,/var/folders/m3/vn1yyrfx7l36cq6p8msc6wt80000gn/T/rustc.qQqNIUT1sO3i/liblazy_static-3a04918be71c80ee.rlib" "-Wl,-force_load,/var/folders/m3/vn1yyrfx7l36cq6p8msc6wt80000gn/T/rustc.qQqNIUT1sO3i/libstd-cb705824.rlib" "-Wl,-force_load,/var/folders/m3/vn1yyrfx7l36cq6p8msc6wt80000gn/T/rustc.qQqNIUT1sO3i/libcollections-cb705824.rlib" "-Wl,-force_load,/var/folders/m3/vn1yyrfx7l36cq6p8msc6wt80000gn/T/rustc.qQqNIUT1sO3i/librustc_unicode-cb705824.rlib" "-Wl,-force_load,/var/folders/m3/vn1yyrfx7l36cq6p8msc6wt80000gn/T/rustc.qQqNIUT1sO3i/librand-cb705824.rlib" "-Wl,-force_load,/var/folders/m3/vn1yyrfx7l36cq6p8msc6wt80000gn/T/rustc.qQqNIUT1sO3i/liballoc-cb705824.rlib" "-Wl,-force_load,/var/folders/m3/vn1yyrfx7l36cq6p8msc6wt80000gn/T/rustc.qQqNIUT1sO3i/liballoc_system-cb705824.rlib" "-Wl,-force_load,/var/folders/m3/vn1yyrfx7l36cq6p8msc6wt80000gn/T/rustc.qQqNIUT1sO3i/liblibc-cb705824.rlib" "-Wl,-force_load,/var/folders/m3/vn1yyrfx7l36cq6p8msc6wt80000gn/T/rustc.qQqNIUT1sO3i/libcore-cb705824.rlib" "-l" "System" "-l" "pthread" "-l" "c" "-l" "m" "-dynamiclib" "-Wl,-dylib" "-l" "compiler-rt"
note: Undefined symbols for architecture x86_64:
  "_enif_make_double", referenced from:
      rustler::wrapper::nif_interface::enif_make_double::h2955724b75cecc61 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$f64$u20$as$u20$types..NifEncoder$GT$::encode::h1b4452714d6d4b10 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$f32$u20$as$u20$types..NifEncoder$GT$::encode::h1c2ffc4881c2903f in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_get_ulong", referenced from:
      ruster_unsafe::enif_get_uint64::h6a6efcdf317b18c4 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      ruster_unsafe::enif_get_uint64::h6a6efcdf317b18c4 in libruster_unsafe-256b634055e24e72.rlib(ruster_unsafe-256b634055e24e72.0.o)
  "_enif_make_ulong", referenced from:
      ruster_unsafe::enif_make_uint64::ha34647124f8445ad in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      ruster_unsafe::enif_make_uint64::ha34647124f8445ad in libruster_unsafe-256b634055e24e72.rlib(ruster_unsafe-256b634055e24e72.0.o)
  "_enif_make_long", referenced from:
      ruster_unsafe::enif_make_int64::h19b8d04a69049b6a in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      ruster_unsafe::enif_make_int64::h19b8d04a69049b6a in libruster_unsafe-256b634055e24e72.rlib(ruster_unsafe-256b634055e24e72.0.o)
  "_enif_get_uint", referenced from:
      rustler::wrapper::nif_interface::enif_get_uint::hec8265bbe0c51e0e in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$u32$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::hc0ae96bb1a8a125d in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$u8$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::h121ec11005986bac in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$u16$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::hafda0f180ac6d8ca in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_get_int", referenced from:
      rustler::wrapper::nif_interface::enif_get_int::h55571de701762d16 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$i32$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::hfabef9a46f52c06d in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$i8$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::h233811501aa78314 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$i16$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::hb8e170e909e86d7d in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_make_int", referenced from:
      rustler::wrapper::nif_interface::enif_make_int::h7f7fa530497562c9 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$i32$u20$as$u20$types..NifEncoder$GT$::encode::ha1c059136fd52252 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$i8$u20$as$u20$types..NifEncoder$GT$::encode::hdf7d5ef7a23e6450 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$i16$u20$as$u20$types..NifEncoder$GT$::encode::h4a4b9280ca8325e2 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_keep_resource", referenced from:
      rustler::wrapper::nif_interface::enif_keep_resource::h48259ec58ff12602 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_release_resource", referenced from:
      rustler::wrapper::nif_interface::enif_release_resource::h1bed4c24409b5214 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_make_resource", referenced from:
      rustler::wrapper::nif_interface::enif_make_resource::hbdef75d2a6655bea in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_alloc_resource", referenced from:
      rustler::wrapper::nif_interface::enif_alloc_resource::hcafb450777244b62 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_make_copy", referenced from:
      rustler::wrapper::nif_interface::enif_make_copy::h69214799fa3b9645 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_is_atom", referenced from:
      rustler::wrapper::nif_interface::enif_is_atom::h4c1e27a13c126b7e in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_get_list_cell", referenced from:
      rustler::wrapper::nif_interface::enif_get_list_cell::h1aab0cf182fd72cd in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_make_uint", referenced from:
      rustler::wrapper::nif_interface::enif_make_uint::h2f5d391bf13c10e8 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$u32$u20$as$u20$types..NifEncoder$GT$::encode::h14d1119c142b082c in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$u8$u20$as$u20$types..NifEncoder$GT$::encode::h39df33241c8c172a in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$u16$u20$as$u20$types..NifEncoder$GT$::encode::hfd6c432f2c86f33a in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_make_map_update", referenced from:
      rustler::wrapper::nif_interface::enif_make_map_update::hb2ec93364aa738a7 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_get_map_value", referenced from:
      rustler::wrapper::nif_interface::enif_get_map_value::hf297cb65056a574d in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_make_map_put", referenced from:
      rustler::wrapper::nif_interface::enif_make_map_put::h9539e1550d86790f in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_open_resource_type", referenced from:
      rustler::wrapper::nif_interface::enif_open_resource_type::h196ab420ef77a458 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_make_new_map", referenced from:
      rustler::wrapper::nif_interface::enif_make_new_map::h04eb30055d0433ea in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_make_badarg", referenced from:
      rustler::wrapper::nif_interface::enif_make_badarg::hfd47f421776299e7 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_get_tuple", referenced from:
      rustler::wrapper::nif_interface::enif_get_tuple::h496dbde1a06b26fa in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_get_long", referenced from:
      ruster_unsafe::enif_get_int64::h7322dfab1d51cfe0 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      ruster_unsafe::enif_get_int64::h7322dfab1d51cfe0 in libruster_unsafe-256b634055e24e72.rlib(ruster_unsafe-256b634055e24e72.0.o)
  "_enif_get_map_size", referenced from:
      rustler::wrapper::nif_interface::enif_get_map_size::hd15a7dd43835f5fa in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_alloc_env", referenced from:
      rustler::wrapper::nif_interface::enif_alloc_env::h104eae5c02c87a95 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_make_binary", referenced from:
      rustler::wrapper::nif_interface::enif_make_binary::h4df56732cd29a1d9 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      rustler::binary::NifBinary::from_owned::hd68ef82867d453c3 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_alloc_binary", referenced from:
      rustler::wrapper::nif_interface::enif_alloc_binary::hc2f02f5b05daa256 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      rustler::binary::OwnedNifBinary::alloc::h83a4138714c8e953 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_release_binary", referenced from:
      rustler::wrapper::nif_interface::enif_release_binary::hcf385eda5649cf90 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$binary..OwnedNifBinary$u20$as$u20$std..ops..Drop$GT$::drop::h6787ff98ae72ec84 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_get_list_length", referenced from:
      rustler::wrapper::nif_interface::enif_get_list_length::he2e2177223e5457e in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_is_empty_list", referenced from:
      rustler::wrapper::nif_interface::enif_is_empty_list::hf97958a62da19d09 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_get_double", referenced from:
      rustler::wrapper::nif_interface::enif_get_double::h8276570c21d114b6 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$f64$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::h6c5508c0ba78eb78 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      _$LT$f32$u20$as$u20$types..NifDecoder$LT$$u27$a$GT$$GT$::decode::ha05b75d016c816c4 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_raise_exception", referenced from:
      rustler::wrapper::nif_interface::enif_raise_exception::h72fc005bcd6c2a0a in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_is_list", referenced from:
      rustler::wrapper::nif_interface::enif_is_list::h76c50d412d0ac05d in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_make_tuple_from_array", referenced from:
      rustler::wrapper::nif_interface::enif_make_tuple_from_array::hd9d4712e9e6f5a51 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_make_map_remove", referenced from:
      rustler::wrapper::nif_interface::enif_make_map_remove::hffb914012c16730b in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_inspect_binary", referenced from:
      rustler::wrapper::nif_interface::enif_inspect_binary::h3e37ee6fd8a4fc76 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
      rustler::binary::NifBinary::from_term::ha2e3c6a8a7e79c98 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_get_resource", referenced from:
      rustler::wrapper::nif_interface::enif_get_resource::he472a38f7fa68a5b in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.o)
  "_enif_make_atom_len", referenced from:
      rustler::wrapper::nif_interface::enif_make_atom_len::h45eb891df1a70a11 in librustler-73f06792a5236e6b.rlib(rustler-73f06792a5236e6b.0.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
error: Could not compile `native`.

To learn more, run the command again with --verbose.
@hansihe
Copy link
Member

hansihe commented Jun 7, 2016

This looks like rusterlium/erlang_nif-sys#3.

Try adding

#![feature(link_args)]
#[link_args = "-flat_namespace -undefined suppress"]
extern {}

to the top of the nif.rs file.

@developerworks
Copy link
Author

Add add above feature code at top of lib.rs like this:

#![feature(link_args)]
#[link_args = "-flat_namespace -undefined suppress"]
extern {}
#![feature(plugin)]
#![plugin(rustler_codegen)]

#[macro_use]
extern crate rustler;
use rustler::{NifEnv, NifTerm, NifError, NifDecoder, NifEncoder};
use rustler::resource::ResourceCell;

rustler_export_nifs!(
    "Elixir.NativeTest",
    [("add", 2, add),
     ("panic_test", 0, panic_test),
     ("struct_argument", 1, struct_argument),
     ("make_resource_struct", 0, make_resource_struct),
     ("read_resource_struct", 1, read_resource_struct),
     ("string_test", 0, string_test)],
    Some(on_load)
);

but the errors raised:

➜  native git:(master) cargo build
    Updating registry `https://github.com/rust-lang/crates.io-index`
   Compiling libc v0.2.11
   Compiling aster v0.16.0
   Compiling lazy_static v0.1.16
   Compiling easy-plugin v0.3.4
   Compiling ruster_unsafe v0.4.0
   Compiling rustler v0.8.3 (file:///Users/hezhiqiang/RustProjects/rustler_issue_16/Rustler)
/Users/hezhiqiang/RustProjects/rustler_issue_16/Rustler/src/codegen_runtime.rs:8:5: 8:24 warning: use of deprecated item: renamed to `catch_unwind`, #[warn(deprecated)] on by default
/Users/hezhiqiang/RustProjects/rustler_issue_16/Rustler/src/codegen_runtime.rs:8 use std::panic::recover;
                                                                                     ^~~~~~~~~~~~~~~~~~~
/Users/hezhiqiang/RustProjects/rustler_issue_16/Rustler/src/codegen_runtime.rs:23:51: 23:58 warning: use of deprecated item: renamed to `catch_unwind`, #[warn(deprecated)] on by default
/Users/hezhiqiang/RustProjects/rustler_issue_16/Rustler/src/codegen_runtime.rs:23     let result: ::std::thread::Result<NIF_TERM> = recover(|| {
                                                                                                                                    ^~~~~~~
   Compiling rustler_codegen v0.8.3 (file:///Users/hezhiqiang/RustProjects/rustler_issue_16/Rustler/rustler_codegen)
/Users/hezhiqiang/RustProjects/rustler_issue_16/Rustler/rustler_codegen/src/resource.rs:66:13: 66:20 warning: unused variable: `builder`, #[warn(unused_variables)] on by default
/Users/hezhiqiang/RustProjects/rustler_issue_16/Rustler/rustler_codegen/src/resource.rs:66         let builder = ::aster::AstBuilder::new().span(span);
                                                                                                       ^~~~~~~
/Users/hezhiqiang/RustProjects/rustler_issue_16/Rustler/rustler_codegen/src/resource.rs:66:13: 66:20 note: in this expansion of easy_plugin! (defined in /Users/hezhiqiang/RustProjects/rustler_issue_16/Rustler/rustler_codegen/src/lib.rs)
   Compiling native v0.1.0 (file:///Users/hezhiqiang/RustProjects/rustler_issue_16/Rustler_Example/native)
src/lib.rs:4:3: 4:4 error: an inner attribute is not permitted in this context
src/lib.rs:4 #![feature(plugin)]
               ^
src/lib.rs:4:3: 4:4 help: place inner attribute at the top of the module or block
src/lib.rs:5:3: 5:4 error: an inner attribute is not permitted in this context
src/lib.rs:5 #![plugin(rustler_codegen)]
               ^
src/lib.rs:5:3: 5:4 help: place inner attribute at the top of the module or block
src/lib.rs:36:5: 36:25 error: macro undefined: 'resource_struct_init!'
src/lib.rs:36     resource_struct_init!(ResourceStructTest, env);
                  ^~~~~~~~~~~~~~~~~~~~
error: aborting due to 3 previous errors
error: Could not compile `native`.

To learn more, run the command again with --verbose.

my rust version is:

➜  native git:(master) ✗ rustc --version
rustc 1.10.0-nightly (62e2b2fb7 2016-05-06)

@developerworks
Copy link
Author

It's fix by adjust the order with:

#![feature(plugin)]
#![plugin(rustler_codegen)]
#![feature(link_args)]
#[link_args = "-flat_namespace -undefined suppress"]
extern {}

#[macro_use]
...
...
...

@developerworks
Copy link
Author

But, it's seems like nif load path is mistake on osx:

➜  Rustler_Example git:(master) ✗ elixir run.exs 
run.exs:34: warning: variable res is unused
** (MatchError) no match of right hand side value: {:error, :on_load_failure}
    (stdlib) erl_eval.erl:670: :erl_eval.do_apply/6


20:05:11.297 [error] Process #PID<0.55.0> raised an exception
** (MatchError) no match of right hand side value: {:error, {:load_failed, 'Failed to load NIF library: \'dlopen(native/target/debug/librust_nif.so, 2): image not found\''}}
    run.exs:12: NativeTest.init/0
    (kernel) code_server.erl:1669: anonymous fn/1 in :code_server.handle_on_load/4

20:05:11.301 [warn]  The on_load function for module Elixir.NativeTest returned {{:badmatch,
  {:error,
   {:load_failed,
    'Failed to load NIF library: \'dlopen(native/target/debug/librust_nif.so, 2): image not found\''}}},
 [{NativeTest, :init, 0, [file: 'run.exs', line: 12]},
  {:code_server, :"-handle_on_load/4-fun-0-", 1,
   [file: 'code_server.erl', line: 1669]}]}


@developerworks
Copy link
Author

developerworks commented Jun 7, 2016

Fixed with:

cp ./native/target/debug/librust_nif.dylib to ./native/target/debug/librust_nif.so

or

ln -s ./native/target/debug/librust_nif.dylib ./native/target/debug/librust_nif.so

@brendanzab
Copy link

This seems quite similar to #12!

@hansihe
Copy link
Member

hansihe commented Jun 7, 2016

Yep, both problems where the same.

@developerworks developerworks changed the title Compile errors Compile errors on OSX Jun 8, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants