Comments (7)
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.
from rustler.
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)
from rustler.
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]
...
...
...
from rustler.
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]}]}
from rustler.
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
from rustler.
This seems quite similar to #12!
from rustler.
Yep, both problems where the same.
from rustler.
Related Issues (20)
- NIF code trying to using MongoDB sync client hangs while trying to connect to DB HOT 2
- Check if Term is float HOT 5
- NifMap expansion error with rustler v0.27.0 HOT 2
- Update changelog for 0.27 HOT 1
- Store rustler template outside of priv/? HOT 2
- how to custom build target arch?
- can you support cargo-zigbuild? HOT 2
- `nif` macro fails with macro arguments HOT 2
- New Binary from Vec or Slice
- Support for enif_monitor_process HOT 1
- resource with lifetime
- Expose `enif_is_process_alive` HOT 4
- rustler errors on OTP26 HOT 1
- How to conveniently work with binaries as vectors of bytes?
- Why does Term::map_from_pairs return a NifResult?
- Support for fully custom `:load_from` for escripts HOT 8
- This OTP release uses the unsupported Erlang NIF version "2.17" HOT 1
- Test NifStruct derived traits
- Running `dialiyzer` with `rustler` 0.30.0 results in "The pattern can never match the type"" HOT 4
- Import structs from a library
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rustler.